• ### Announcements

#### Archived

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

# Integer sizes...

## Recommended Posts

Am I correct in saying the integer size for most computers is 2 bytes? Thanks in advance. Noods

##### Share on other sites
Although this is implementation-defined in C++, it will most often be 4 bytes (on 32 bit computers).

##### Share on other sites
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 2cout << sizeof(bar) << endl; // will probably be 4

Anthracks

##### 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 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

• ### Forum Statistics

• Total Topics
627701
• Total Posts
2978697

• 21
• 14
• 12
• 10
• 12