About the original code, anti-code complement of understanding

In the last semester learning c ++ c language when it came into contact with the original code, anti-code and complement these three concepts.

First of all, my own understanding, the original code, anti-code and complement these three concepts are based on binary terms.

Represents a positive number, the sign bit is a negative number "1" when the original code comprises a sign bit and a bit value, the absolute value of the value is the true value of the bit, the sign bit is "0." Here can be seen, the original code and the decimal integer of "0" have two kinds of representation, "+0" and "-0" is not the same, an example of 8-bit machines, the integer "+0" original code is 0,0000000; integer "-0" original code is 1,0000000; fractional "+0" original code is 0.0000000, decimal "-0" original code is 1.0000000.

Anti-code with the original code is a positive number, the same; negative, anti-code is the original code except the sign bit, the other bits Bitwise. 8-bit machine, for example, the integer "+0" as the original code 0,0000000 anti code 0,0000000; integer "-0" of the original code 1,0000000 anti code 1,1111111; fractional "+0" is 0.0000000 original code, anti-code is 0.0000000; fractional "-0" original code is 1.0000000, decimal "-0" anti-code is 1.1111111.

Complement, because I think it is because the use of the original code to be wrong in the calculation process, so the introduction of a complement this concept. Complement subtraction is put into the computer adding the key code. Complement positive number of the same original code thereto; negative complement is added to the last bit 1 in its inverted.

In Java, using the complement.

Guess you like

Origin www.cnblogs.com/shumouren/p/11571756.html