These days, the interview, the interview when a lot of knowledge point is also very unfamiliar, this two days first to review the Java Foundation, there is a period of time did not write a blog, today, first talk about the conversion of the system.
1. Binary number of the original code, complement and anti-code
1): For positive number of the original code, complement and anti-code are the same, not discussed here.
2) Next we discuss negative binary source code, inverse code, and complement
The original code of the negative binary: calculates the binary value of the absolute value first, then the binary each bit of data is reversed, and finally add 1. The binary inversion form of negative numbers is the corresponding integer binary negation and then the addition of a
Eg:-32
First step: Calculate the binary number of absolute values: 32 (10) =0010 0000 (2)
Step two: Take the reverse: 1101 1111
Step three: Add one: 1110 0000
So-32 of the original code is: 1110 0000
Anti-code: Negative number of the inverse code equals: The original code the highest bit unchanged, the remaining bits are reversed.
Eg:-32
Original code: 1110 0000
Anti-code: 1001 1111
Complement: The complement of the negative is equal to: the highest position is unchanged, the remaining bits are reversed, and the last one
Eg:-32
Original code: 1110 0000
Anti-code: 1001 1111
Complement: 1010 0000
2. Conversion between binary number and octal, decimal, and hexadecimal numbers
Eg: for-10
The original code: three steps, absolute value, reverse, and finally add 1. So the original code: 1111 0110
Anti-code: The original code is the highest bit unchanged, the remaining bits are reversed: 1000 1001
Complement: The highest position is unchanged, the remaining bits are reversed and the last one is added: 1111 01111
The conversion between the rest of the binary and octal, decimal, and hexadecimal is similar to the conversion between binary and decimal.
Java Review (1)