Integer sizes...

Started by
3 comments, last by Noods 22 years, 3 months ago
Am I correct in saying the integer size for most computers is 2 bytes? Thanks in advance. Noods
Advertisement
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
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
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.
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.

This topic is closed to new replies.

Advertisement