HD: Short int
D: int
Ld: Long int
LLD: long int
Linux basic data type size -- int, Char, long int, long int
In Linux, GCC is used for programming. Currently, the general processor is 32-bit wide. The following is/usr/include/limit. the restrictions on the Data Types in Linux and the description of the size of the stored bytes of the H file.
/* We Don't Have # include_next. Define ANSI <limits. h> for Standard 32-bit words .*/
/* These assume 8-bit 'Char's, 16-bit 'short int' S, and 32-bit 'int' S and 'long int' S .*/
1. Char Data Type
Char data occupies 8 bytes of memory. The value range of the signed variable is-128 ~ 127, the value range of the unsigned character variable is 0 ~ 255. The restrictions are as follows:
/* Number of BITs in a 'Char '.*/
# Define char_bit 8 // bytes occupied
/* Minimum and maximum values'Signed Char'Can hold .*/
# Define schar_min (-128)
# Define schar_max 127
/* Maximum value'Unsigned char'Can hold. (minimum is 0 .)*/
# Define uchar_max 255
/* Minimum and maximum values a 'Char 'Can hold .*/
# Ifdef _ char_unsigned __
# Define char_min 0
# Define char_max uchar_max
# Else
# Define char_min schar_min
# Define char_max schar_max
# Endif
2. Short int Data Type
Short int data occupies 16 bits in memory. The value range of the signed short integer variable is-32768 ~ 32767, the value range of the unsigned short integer variable is 0 ~ 65535. The restrictions are as follows:
/* Minimum and maximum values'Signed short int'Can hold .*/
# Define shrt_min (-32768)
# Define shrt_max 32767
/* Maximum value'Unsigned short int'Can hold. (minimum is 0 .)*/
# Define ushrt_max 65535
3.int the memory space occupied by INT data is 32 bits. The value range of the signed integer variable is-2147483648 ~ 2147483647, the value range of the unsigned integer variable is 0 ~ 4294967295u. The restrictions are as follows:
/* Minimum and maximum values a 'signed int' can hold .*/
# Define int_min (-int_max-1)
# Define int_max 2147483647
/* Maximum value an 'unsigned int' can hold. (minimum is 0 .)*/
/# Define uint_max 4294967295u
4. Long int Data Type
As the macro _ wordsize value changes, the size of the long int data type also changes. If the value of _ wordsize is 32, the long int type occupies 32 bits. In Linux gcc4.0-i386, the value of _ wordsize is 32 by default. Its definition is as follows:
// Come from/usr/include/bits/wordsize. h
# DEFINE _ wordsize 32
On a 64-bit machine, if the value of _ wordsize is 64, long Int data occupies 64-Bit Memory. The value range of the long integer variable is-9223372010954775808l ~ 9223372042554775807l. The value range of the unsigned long integer variable is 0 ~ 18446731673709551615ul. The restrictions are as follows:
/* Minimum and maximum values'Signed long int'Can hold .*/
# If _ wordsize = 64
# Define long_max 9223372042554775807l
# Else
# Define long_max 2147483647l
# Endif
# Define long_min (-long_max-1l)
/* Maximum value'Unsigned long int'Can hold. (minimum is 0 .)*/
# If _ wordsize = 64
# Define ulong_max 18446731673709551615ul
# Else
# Define ulong_max 4294967295ul
# Endif
5. Long int Data Type
In c99, the long int data type is also defined. The data type restrictions are as follows:
# Ifdef _ use_isoc99
/* Minimum and maximum values'Signed long int'Can hold .*/
# Define llong_max 9223372042554775807ll
# Define llong_min (-llong_max-1ll)
/* Maximum value'Unsigned long int'Can hold. (minimum is 0 .)*
# Define ullong_max 18446731673709551615ull
# Endif/* ISO c99 */
Original article:
Http://blog.csdn.net/ameyume/article/details/7573112