/* We don't have #include_next. Define ANSI 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. */
/* Number of bits in a 'char'. */ # define CHAR_BIT 8 //所占字节数 /* Minimum and maximum values a 'signed char' can hold. */ //有符号字符型范围 # define SCHAR_MIN (-128) # define SCHAR_MAX 127 /* Maximum value an '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数据类型
short int类型数据所占内存空间为16位。其中有符号短整型变量取值范围为?32768~32767,无符号短整型变量取值范围为0~65535。其限制如下:
/* Minimum and maximum values a 'signed short int' can hold. */ // 有符号短整型范围 # define SHRT_MIN (-32768) # define SHRT_MAX 32767 /* Maximum value an 'unsigned short int' can hold. (Minimum is 0.) */// 无符号短整型范围 # define USHRT_MAX 65535
/* 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
//come from /usr/include/bits/wordsize.h #define __WORDSIZE 32
在64位机器上,如果__WORDSIZE的值为64, long int类型数据所占内存空间为64位。其中有长整型变量取值范围为-9223372036854775808L~3372036854775807L,无符号长整型变量取值范围为0~18446744073709551615UL。其限制如下:
/* Minimum and maximum values a 'signed long int' can hold. */ //有符号长整形范围 # if __WORDSIZE == 64 # define LONG_MAX 9223372036854775807L # else # define LONG_MAX 2147483647L # endif # define LONG_MIN (-LONG_MAX - 1L) /* Maximum value an 'unsigned long int' can hold. (Minimum is 0.) *///无符号长整形范围 # if __WORDSIZE == 64 # define ULONG_MAX 18446744073709551615UL # else # define ULONG_MAX 4294967295UL # endif
5.long long int数据类型
在C99中,还定义了long long int数据类型。其数据类型限制如下:
# ifdef __USE_ISOC99 /* Minimum and maximum values a 'signed long long int' can hold. *///无符号长长整形范围 # define LLONG_MAX 9223372036854775807LL # define LLONG_MIN (-LLONG_MAX - 1LL) /* Maximum value an 'unsigned long long int' can hold. (Minimum is 0.) *///有符号长长整形范围 # define ULLONG_MAX 18446744073709551615ULL # endif /* ISO C99 */
文章评论(0条评论)
登录后参与讨论