For example, you can assign short to an int variable or a long variable.
Of course, both unsigned shaping and signed shaping have conversion mechanisms, which can realize conversion. Depending on the implementation of the compiler, the specific conversion will be different.
For example, some compilers are based on standard expressions with signed shaping.
-1 is expressed as1111in binary byte order (that is, it is inverted and added as usual)-but in a positive integer, it is 65438+.
So it's similar to converting -200 into a positive integer.
The conversion mechanism is divided into type promotion conversion and type conversion, and the promotion conversion is automatic.
So when you assign a value to an unsigned integer, the compiler will implement the conversion mechanism inside C++ to make it a reasonable value.