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位表示尾數。