C里面的类型字节长度和范围
32位平台
char 1个字节8位
short 2个字节16位
int 4个字节32位
long 4个字节
long long 8个字节
指针 4个字节
64位平台
char 1个字节
short 2个字节
int 4个字节
long 8个字节
long long 8个字节
指针 8个字节
范围
char -128 ~ +127 (1 Byte)
short -32767 ~ + 32768 (2 Bytes)
unsigned short 0 ~ 65536 (2 Bytes)
int -2147483648 ~ +2147483647 (4 Bytes)
unsigned int 0 ~ 4294967295 (4 Bytes)
long long -9223372036854775808 ~ +9223372036854775807 (8 Bytes)
double 1.7 * 10^308 (8 Bytes)
双精度浮点数(double)使用 64 位(8字节) 来存储一个浮点数。 它可以表示十进制的15或16位有效数字,其可以表示的数字的绝对值范围大约是\( 1.7 \times 10^{-308} , \text{1.7} \times 10^{308} \)
sign bit(符号): 用来表示正负号,1bit
exponent(指数): 用来表示次方数,11bits
mantissa(尾数): 用来表示精确度,52bits
\(\text{Mantissa} \times \text{2}^\text{exponent}\)
单精度浮点数使用32位(4字节)存储。
第1位表示正负,中间8位表示指数,后23位表示尾数。