Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - The range of int values in c language under 64-bit system
The range of int values in c language under 64-bit system
In the 64-bit computer, int occupies 32 bits, and its value range is-2147483648 ~ 2147483647 (-232 ~ 232-1).

For int type:

Shortint type may take up less storage space than int type. C ensures that the length of short type is at least 16 bits, which is used when only decimal values are needed to save space.

Longint type (or long type for short) may occupy more storage space than int type, and C guarantees that the short type is at least 32 bits long, which is used when using large branches.

Longlongint type (or abbreviated as longing type) may take up more storage space than Long type. C guarantees that the length of short type is at least 64 bits, and it is used when using larger values.

Extended data

Integer overflow in C language

Int is 4 bytes and 32 bits, where the first bit is a positive number of 0 and a negative number of 1. So for

The largest positive number can be expressed as 0x7fffffff(7 is binary 011,and f is binary11).

The largest negative number (-1) can be expressed as 0xffffffff.

The smallest negative number can be expressed as 0x80000000(8 the binary of 8 is 1000).

The source code with a negative number as a positive number takes the complement first, and then takes the complement. The process is as follows:

The original codes of 1 and-1 are:10000000000000000000001.

2. Inverse code:1111111. 1 1 1 1 1 1 1 1 1 10

3. Complement:1111111/kloc-0. 1 1 1 1 1 1 1 1 1 1 1