Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - The problem of finding the complement of the original code in C language
The problem of finding the complement of the original code in C language
Complement to find the original code?

Do you think the original code of complement is one-to-one correspondence?

Eight-bit complement can represent the signed number-128 ~ 127.

Eight-bit source code can represent signed number-127 ~ 127.

Therefore,-128 has only the complement, but no original code.

In 8-bit complement, 0~ 127 is stored as positive original code.

The other 128~255 is the representative number-128 ~- 1

Will. 129~255 "minus plus one" is the original code of-127 ~- 1

And 128 has no corresponding source code.

The process of converting eight-bit's complement into the original code is as follows:

Unsigned character acquisition bit (unsigned character value)

{//Value: 0~255

If (value == 128) printf ("this complement has no original code");

Or what? If (value & gt128) value = ~ value+1+128;

//If it is negative, take the inverse plus one and add the sign bit to get the original code.

Returnvalue// returns the original code.

}