View Full Version : size of integer
13th December 2011, 01:01 PM
In ANSI -C by Ritchie
It was defined as
int an integer, typically reflecting the natural size of integers on the host machine.
How to find the natural size of integers on the host machine.
13th December 2011, 01:06 PM
13th December 2011, 05:18 PM
The "sizeof(type)" operator will give you the size of any C type (including structs), in terms of the number of bytes needed to store the type (excluding trailing alignment). If you need bits, multiply by the CHAR_BIT constant.
15th December 2011, 08:17 PM
Note that different compilers may have different ideas about "natural size of integers", even at the same system.
If you want to be really sure of some size, K&R also defines a minimally required size (eg 'int' is at least 16 bit (iirc)).
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.