Archived

This topic is now archived and is closed to further replies.

Integer sizes...

This topic is 5817 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I think nowadays, unless you specify short instead of int, integers are 32-bit (or 4 bytes).
  
short foo;
int bar;

cout << sizeof(foo) << endl; // will probably be 2

cout << sizeof(bar) << endl; // will probably be 4



Anthracks

Share this post


Link to post
Share on other sites
the sizeof(int) while generally match the bit depth of the internal data bus of the CPU, since this is the most efficient way of transferring a piece of data (generally speaking). it just so happens that the most widely acclaimed processor (x86, starting at 386 and up is 32-bit). however, the Itanium is 64-bit, thus an "int" on an Itanium processor will most likely be 64-bit.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

Share this post


Link to post
Share on other sites
when Writing code in which the size of an integer is important to maintain through any compilation method, use the __int data types for dos you would want __int16, win 9x __int32 (currently standard), or for the future __int64 they work with the microsoft compilers,and their is an option to change the default of int to any of these, but I can''t remember what it is at this time. if you get an error using the __int16''s it reads it as a short, the __int8''s as char, and __int32''s as a normal int

Share this post


Link to post
Share on other sites