Results 1 to 7 of 7

Thread: sizeof();

  1. #1

    Thread Starter
    Member Benjamin's Avatar
    Join Date
    Nov 2000
    Posts
    48

    Question

    can anybody tell me what the sizes are for:

    int
    long
    float
    double
    char


    and not in bytes...

    the max size I mean...



    Thanks,
    Dennis
    -Dennis
    [email protected]
    Ever stop to think, and forget to start again?


    The end justifies the means
    http://www.cfm-resources.com/d/dewrenn
    http://www.phpsquare.com

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Maximum values for integral types are (2^sizeof(type)-1)

    NOTE: All values are UNSIGNED!

    int = this is system dependent, on 32bit int=long, on 16bit int=short - 32bit = 4294967295
    long = 4294967295
    char = 255

    Also:
    float = 3.4E +/- 38 (7 digits)
    double = 1.7E +/- 308 (15 digits)
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Member Benjamin's Avatar
    Join Date
    Nov 2000
    Posts
    48
    so an int is:
    32768

    ?
    -Dennis
    [email protected]
    Ever stop to think, and forget to start again?


    The end justifies the means
    http://www.cfm-resources.com/d/dewrenn
    http://www.phpsquare.com

  4. #4

    Thread Starter
    Member Benjamin's Avatar
    Join Date
    Nov 2000
    Posts
    48
    (signed)
    -Dennis
    [email protected]
    Ever stop to think, and forget to start again?


    The end justifies the means
    http://www.cfm-resources.com/d/dewrenn
    http://www.phpsquare.com

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    No. And Yes.

    If you're using a 16bit system, an int is 16 bits. On a 32bit system, an int is 32 bits. It's matched to the size of the system word.

    So:

    16bit - signed int = 32767 (starts at 0)
    32bit - signed int = 2147483647
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    HEhehe, don't you know anything Benji?

    Acting like a 14 year old huh^?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7

    Thread Starter
    Member Benjamin's Avatar
    Join Date
    Nov 2000
    Posts
    48
    I'm only acting like I dont know anything...
    -Dennis
    [email protected]
    Ever stop to think, and forget to start again?


    The end justifies the means
    http://www.cfm-resources.com/d/dewrenn
    http://www.phpsquare.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width