Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - The unsigned character type in C language, what does this unsigned character mean?
The unsigned character type in C language, what does this unsigned character mean?
The unsigned character type in C language is actually an integer with the length of 1 byte, and it is also an integer type in essence, which is usually used to store ASCII codes.

Integers are divided into unsigned and signed types. The default integer variable is a signed type, and char is a bit special. To declare an unsigned type, add unsigned before the type.

The difference between an unsigned integer and a signed integer is that an unsigned type can store twice as many positive numbers as a signed integer, because a signed type stores most significant bit, while an unsigned type stores all numbers.

In the 16 bit system, the range of data that int can store is -32768~32767, and the range of data that unsigned can store is 0~65535.

Extended data

Integer classification:

fundamental form

The type specifier is int, which takes up 4 bytes of memory (there may be differences between different systems, here it was originally 2, and it was verified that the windows system was 4, and so was the VAX system), and its value is a basic integer constant.

Short integer

The type specifier is short int or short' c110f1. For different compilation systems, the range of bytes and values occupied will be different. For 16 word machine, short int takes up 2 bytes, and in most 32-bit machines, short int takes up 4 bytes. But in general, short int is at least 16 bits, that is, 2 bytes.

Long integer

The type specifier is long int or long, occupying 4 bytes of memory, and its value is long integer constant. In any compilation system, long integers account for 4 bytes. Generally speaking, its range of bytes and values is the same as that of the basic type.

Unsigned type

The type specifier is unsigned. In compiling system, signed number and unsigned number are distinguished by how to interpret most significant bit in bytes. If most significant bit is interpreted as a data bit, integer data is represented as an unsigned number.

C++ Language Programming (4th Edition) Zheng Li? Tsinghua University Publishing House, edited by Dong Yuan and He Jiangzhou.

Chapter II C++ Simple Programming? 2.2 Basic data types and expressions

Baidu encyclopedia-unsigned integer

Baidu Encyclopedia-Integer Variable