Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What is the difference between int and short variables in c language?
What is the difference between int and short variables in c language?
1, the bytes occupied will vary according to the model:

In a general computer, int occupies 4 bytes and 32 bits. In previous microcomputers, int occupied 2 bytes, 16 bits. In 32-bit platforms such as windows(32-bit), the short is generally 16 bits.

2. Different numerical ranges:

In a general computer, the data range of Int is-2147483648 ~ 2147483647 [-231~ 231]. In previous microcomputers, the data range of int was -3228. c++ & amp; Cshort is a data type ranging from -32768 to +32767.

Extended data:

Other classifications of integer data:

1, long integer: the type specifier is long or long, occupying 4 bytes of memory.

2. Unsigned type: The type specifier is unsigned. Unsigned types can match the above three types:

3. unsigned basic type: the type specifier is unsignedint or unsigned.

4.unsignedshort integer: the type descriptor is unsigned short.

5.unsignedlong integer: the type descriptor is unsigned long.

Short length rule: according to different program compilers, the number of bytes defined by short is different. The short integer variable defined by the standard cannot be less than 16 bits, that is, two bytes. Limits.h in the compiler header folder defines the size that short can represent: short minimum ~ SHRT _ maximum. In 32-bit platforms such as windows(32-bit), the short is generally 16 bits.

Baidu encyclopedia -INT

Baidu encyclopedia-short