Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What does this "symbol" mean in unsigned integer and signed integer in C language? Please give an example.
What does this "symbol" mean in unsigned integer and signed integer in C language? Please give an example.
Refers to whether the most significant bit of an integer is used as a sign bit. Modern computers generally use the highest bit 1 to represent negative numbers, and 0 represents non-negative numbers; Store negative numbers in two's complement form.

0xf0, binary 0b1111000.

Signed number, most significant bit is the sign bit, which means-16. The calculation process of complement is to ignore the sign bit, and add 1 after the other bits are inverted, that is, 0b11000->; 0b 000 1 1 1 1->; 0b00 1 0000 = 16。 Then add a minus sign to get-16.

Unsigned number, the highest bit is not the sign bit, which means 240. That is 128+64+32+ 16 = 240.

In addition, when expanding, the signed number is extended to the highest bit, and the unsigned number is extended to 0.

When 0xf0 is extended to 16, the highest bit is extended to 1 to get 0b11111. Ensure that the signed number remains unchanged after expansion. When doing unsigned numbers, extend 0 to get 0b0000000111110000. This value has not changed before and after expansion.