number of bytes for a type in C++

Discussion in 'C++' started by jrefactors@hotmail.com, Dec 10, 2004.

  1. Guest

    In C++, the amount of memory used to store int is 4 bytes, or dependent
    upon the hardware?
    I think still dependent on the machine, since C++ compiler is platform
    dependent.

    Please advise. Thanks
     
    , Dec 10, 2004
    #1
    1. Advertising

  2. I believe that the standard guarantees minimum ranges for intrinsic
    types. For example, I believe that the minimum range for type int is
    [-32768, +32767].

    Regards,

    Jon Trauntvein
     
    JH Trauntvein, Dec 10, 2004
    #2
    1. Advertising

  3. wrote:
    > In C++, the amount of memory used to store int is 4 bytes, or dependent
    > upon the hardware?
    > I think still dependent on the machine, since C++ compiler is platform
    > dependent.


    You think right.
     
    Victor Bazarov, Dec 10, 2004
    #3
  4. Guest

    It is depending upon the hardware.

    According to TCPPPL,
    this is what guaranteed about the sizes of fundamental types

    1 = sizeof(char) <= sizeof(short) <= sizeof(int) <=sizeof(long)
    1<= sizeof(bool) <= sizeof(long)
    sizeof(char) <=sizeof(wchar_t) <= sizeof(long)
    sizeof(float) <= sizeof(double) <= sizeof(long double)
    sizeof(N) = sizeof(signed N) = sizeof(unsigned N)
     
    , Dec 10, 2004
    #4
  5. On 10 Dec 2004 09:07:28 -0800, in comp.lang.c ,
    wrote:

    >It is depending upon the hardware.


    And the compiler. Think about old DOS compilers.

    --
    Mark McIntyre
    CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
    CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
     
    Mark McIntyre, Dec 10, 2004
    #5
  6. writes:
    > In C++, the amount of memory used to store int is 4 bytes, or dependent
    > upon the hardware?
    > I think still dependent on the machine, since C++ compiler is platform
    > dependent.


    In C, it's dependent on the implementation, with some specific
    constraints imposed by the standard.

    But since your question is about C++, cross-posting it to comp.lang.c
    was a bad idea.

    Followups redirected.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Dec 10, 2004
    #6
  7. Rolf Magnus Guest

    Keith Thompson wrote:

    > writes:
    >> In C++, the amount of memory used to store int is 4 bytes, or dependent
    >> upon the hardware?
    >> I think still dependent on the machine, since C++ compiler is platform
    >> dependent.

    >
    > In C, it's dependent on the implementation, with some specific
    > constraints imposed by the standard.


    The same is true for C++. The rules regarding integer type sizes are the
    same in C++ as in C, with the exception that C++ doesn't know the "long
    long" type.
     
    Rolf Magnus, Dec 10, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason Collins
    Replies:
    3
    Views:
    6,019
    Jason Collins
    Feb 18, 2004
  2. Carl Muller

    number of bytes for a type in C++

    Carl Muller, Dec 12, 2004, in forum: C++
    Replies:
    0
    Views:
    352
    Carl Muller
    Dec 12, 2004
  3. mrby

    4-bytes or 8-bytes alignment?

    mrby, Nov 2, 2004, in forum: C Programming
    Replies:
    8
    Views:
    422
    Mark McIntyre
    Nov 2, 2004
  4. number of bytes for a type in C++

    , Dec 10, 2004, in forum: C Programming
    Replies:
    5
    Views:
    346
    Keith Thompson
    Dec 10, 2004
  5. Carl Muller

    number of bytes for a type in C++

    Carl Muller, Dec 12, 2004, in forum: C Programming
    Replies:
    3
    Views:
    342
    hari4063
    Dec 13, 2004
Loading...

Share This Page