C/C++語言有一組基本類型,對應於計算機的基本存儲單元和使用這些單元去保存數據的一些常用方式:
基本數據類型如下:
char
Character or small integer.
1byte
signed: -128 to 127short int
(short
)
Short Integer.
2bytes
signed: -32768 to 32767int
Integer.
4bytes
signed: -2147483648 to 2147483647long int
(long
)
Long integer.
4bytes
signed: -2147483648 to 2147483647bool
Boolean value. It can take one of two values: true or false.
1byte
true
or false
float
Floating point number.
4bytes
+/- 3.4e +/- 38 (~7 digits)
double
Double precision floating point number.
8bytes
+/- 1.7e +/- 308 (~15 digits)
long double
Long double precision floating point number.
8bytes
+/- 1.7e +/- 308 (~15 digits)
wchar_t
Wide character.
2 or 4 bytes
1 wide character