Skip to main content
GameDev.net gamedev.net
🔒 Locked

Integer sizes...

Started by Noods Jan 9, 2002 at 9:40 PM 3 replies 300+ views
Original Post
Noods
Noods
Am I correct in saying the integer size for most computers is 2 bytes? Thanks in advance. Noods
Martee
Martee
Although this is implementation-defined in C++, it will most often be 4 bytes (on 32 bit computers).
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
Anthracks
Anthracks
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
jenova
jenova
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.
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.
Sulgurth
Sulgurth
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
As humans we are all gods, just to different extents of power.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.