C ++ has four built-in arithmetic types: integer, floating point, single character, and Boolean value. An integer or floating point number. A single character can be of two types: signed and unsigned. The Boolean value does not exist. It is easy to understand the signed and unsigned types of integers and floating-point numbers. For example, the int range in general books is-32700--32700: unsigned int range: 0--65500. (Integer, floating point number is signed by default. That is, int, float is actually signed int and signed float)
The question is now
Start with c ++ primer.
Different from other integer types, char has three different types: normal char, unsigned char, and signed char. Although char has three different types, there are only two representation methods. You can use unsigned char or signed char to represent the char type. The char representation is determined by the compiler. "
Char is a character type. The ASCII code must be 0 to 127 characters in total. The signed char range is-127-127 or-128-128. The unsigned char range is 0-255. Both signed char and unsigned char can be used. enough to complete their own tasks. Char is implementation-related. You can add the option-funsigned-char during gcc compilation so that char is unsigned char by default.
There are three types of char, but there are only two Representation Methods. here we need to understand that char and signed char are different types, although in many cases signed char is the default option of char.
In c ++, it is legal to assign a negative value to the unsigned type. The result is that the negative value evaluates the modulo value of this type. Assign-1 to unsigned char and the result is 255.
So what are the functions of unsigned char? C ++ does not have a built-in byte data structure.
typedef unsigned char byte typedef unsigned char byte
Customize.
It is quite convenient to use when applying for memory and bit operations.
We usually do not have special requirements when using it. We only need to use char. I think the lower-layer operations will use unsigned char.