Integer Types (int, long and long long)
If you are curious about the integer types in the mbed compiler, I have copied a test program IntegerTypes from http://home.att.net/~jackklein/c/inttypes.html and the output is as follows:
Size of Boolean type is 1 byte(s) Number of bits in a character: 8 Size of character types is 1 byte Signed char min: -128 max: 127 Unsigned char min: 0 max: 255 Default char is unsigned Size of short int types is 2 bytes Signed short min: -32768 max: 32767 Unsigned short min: 0 max: 65535 Size of int types is 4 bytes Signed int min: -2147483648 max: 2147483647 Unsigned int min: 0 max: 4294967295 Size of long int types is 4 bytes Signed long min: -2147483648 max: 2147483647 Unsigned long min: 0 max: 4294967295 Size of long long types is 8 bytes Signed long long min: -9223372036854775808 max: 9223372036854775807 Unsigned long long min: 0 max: 18446744073709551615
Note that int and long are the same size and if you want a 64 bit integer then you need to use long long (or unsigned long long).
6 comments
You need to log in to post a comment
If you need a specific size and want to make sure, include stdint.h and use [u]int_N_t types.