Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How many bits do various data types occupy in C language?
How many bits do various data types occupy in C language?
(1) 32-bit platform:

Divided into signed type and unsigned type.

Signed type:

Short occupies two bytes of memory, ranging from-215 ~ (215-1).

Int occupies four bytes of memory, ranging from-231~ (231-1).

Long occupies four bytes of memory, ranging from -2 3 1 to 2 3 1- 1.

Unsigned type: the highest bit does not represent the sign bit.

The unsigned short occupies two bytes of memory, ranging from 0 to 2 16- 1.

Unsigned int occupies four bytes of memory, ranging from 0 to 2 32- 1.

The unsigned long type occupies four bytes of memory, ranging from 0 to 2 32- 1.

Real variable:

There are two forms of single-precision floating point and double-precision double-precision floating point:

Float: four bytes, providing 7~8 significant digits.

Double: Take eight bytes and provide 15~ 16 significant digits.

(2) 16-bit platform:

1) Integer (basic type): the type specifier is int, which takes up 2 bytes of memory.

2) short integer: the type specifier is short int or short. The bytes occupied and the range of values are the same as integer (basic type).

3) long integer: The type specifier is long int or long, occupying 4 bytes of memory.

Unsigned: The type specifier is unsigned.

Unsigned types can match the above three types:

Various unsigned types occupy the same number of bytes in memory space as the corresponding signed types. However, because the sign bit is omitted, it cannot represent a negative number.

Real variable:

It can be divided into single precision (floating point type), double precision (double type) and long double precision (long double type).

Single-precision type occupies 4 bytes (32 bits) of memory space, its numerical range is 3.4e-38 ~ 3.4e+38, and only 7 significant digits can be provided.

Double-precision type occupies 8 bytes (64 bits) of memory space, and its numerical range is1.7e-308 ~1.7e+308, which can provide 16 significant digits.

16 bytes (128 bits) of long double-precision memory space can provide 18- 19 bits of significant digits.