C ++ short / int / long / long long data types, etc. Size

Table 1 Data Type Integer
type of data Byte size Value range
short int (short integer) 2 bytes -32 768 〜+32 767
Short int unsigned
(unsigned short)
2 bytes 0 〜+65 535
int (integer) 4 bytes -2 147 483 648 〜+2 147 483 647
unsigned int (unsigned int) 4 bytes 0 〜4 294 967 295
long int (Long) 4 bytes -2 147 483 648 〜+2 147 483 647
Long int unsigned
(unsigned long)
4 bytes 0 〜4 294 967 295
long long int (long integer) 8 bytes -9 223 372 036 854 775 808~9 223 372 036 854 775 807
Long Long int unsigned
(unsigned long integer)
8 bytes 048 446 744 073 709 551 615

Note that, long integers, and unsigned long integer is introduced in C ++ 11.

 

1, plastic: Indicates the type of integer arithmetic, character, and Boolean values ​​collectively;

2, there are two types of characters: char and wchar_t, char type is usually a single byte, for extensions wchar_t character sets, such as Japanese and Chinese characters, these characters can not be represented by a single char;

3, short, int, long plastic types are represented, in general (32-bit machines), accounting for 16 Short, two bytes; int account 32 (The system may be, the 32-bit unit of 4 bytes) , four bytes; int Long and 32 on the same machine, but also four bytes (in C ++ Primer sense so this notion is incorrect, fishes 1 word = 2 bytes)

4, by default, int, short, long is signed, i.e. Signed;

5, plastic and other different, char expressed in three ways: ordinary char, unsigned char, signed char. Although there are three different types, but only two are represented. Can represent unsigned char or char type signed cahr specific embodiment which may be used by the compiler.

6, integer assignment: When out of range of a value is assigned to a variable, how would you assign it? Answer: determined by the compiler, but usually takes a value after the value of the number of types of modulo value (but will not guarantee that all compilers so treated), EG 336 attempts to store 8-bit unsigned char , the actual assignment of the 80, 80 because the value 336 modulo 256, Similarly, if the assigned -1 unsigned char 8 bits, then the result is 255, 255 because the post 256 is -1 modulo value;

7, a float float, double, long Double represent single precision, double precision, extended precision floating-point, typically 32-bit float, double for the 64-bit, long using 96 or 128-bit. Type range determines the effective number of digits contained in the floating-point number, the actual procedure for, float type can ensure significant digits of 6 bits, and at least a double guarantee significant digits of 10 bits.

8, C ++ standard does not specify how many of each type of account, saying only that "sizeof (long)> = sizeof (int)> = sizeof (short)", so the specific number of bytes are determined based compiler .
----------------

Guess you like

Origin www.cnblogs.com/sylar5/p/11520264.html