1.int type variables occupy the same storage space as machine words, that is, 4 bytes in a 32-bit system; 8 bytes in a 64-bit system;
However, double variables generally occupy 8 bytes, and double variables occupy no less storage space than int variables.
2. The range of values represented by double is larger than that represented by int, and the conversion from double value to int value will be rounded, resulting in loss of accuracy.
Extended data
Easy plastic surgery
1.shaping has char, short, int, long and long long, and these five are also signed by default;
Rule: short has at least 16 digits; Int is at least the same as short; Long is at least 32 bits long and at least as long as int; Long Long is at least 64 bits long and at least as long as Long.
Among them, the last four digits have unsigned variants. Not signed? Short and unsigned? int、unsigned? Long and unsigned? For a long time.
Notice that unsigned itself is unsigned? Short for int.
It can be seen that the only difference between 32-bit computer and 64-bit computer is the size of int and pointer, where int takes up 2 bytes on 32-bit computer and 4 bytes on 64-bit computer. The pointer size is the same as the int size.
2.wchar_t
Char is an 8-bit character type and can only contain 256 characters at most. Many foreign character sets contain more than 256 characters and cannot be represented by char.
The data type of Wchar_t is generally 16 bit or 32 bit.
In a word, wchar_t can represent far more characters than char type.
The wprintf () function in standard C++ and the classes and objects in iostream class library can provide operations related to wchar_t wide character types.
3.++ 1 1 new types: char 16_t and char32 _ t.
Char 16 _ T: 16 bit unsigned->; Prefix u indicates
Char32 _ t: 32-bit unsigned->; Prefix u indicates
Second, floating-point type
There are three kinds of floating point, floating point, double floating point and long double floating point.
Rule: float is at least 4 bytes; Double must be at least 6 bytes and not less than float;; There are at least as many longdouble as doubles.
Usually floating-point 32 bits, double 64 bits, long double 80, 96 bits or 128 bits. I measured a 64-bit long double on VS20 13.
reference data
Baidu encyclopedia -C++
Baidu Encyclopedia-Data Type