This introduces binary, decimal, hexadecimal conversion
A basic concept:
① Digital: the number of elements used to represent binary
- binary binary numbers: 0,1
- decimal decimal Digital: 0,1,2,3,4,5,6,7,8,9
- Digital hexadecimal hex: 0,1,2,3,4,5,6,7,8,9, A, B, C, D, E, F
② base: the number of digital, three notations were 2,10,16
③ bit weights: the unit is made of each bit weights corresponding to a fixed position; values for each digital representation of the digital value * = right bit position is located, for example ten, two, one hundred, etc.
Summary: (N) R = A n-. 1- R n--. 1 + A n-2- R n--2 + ...... + A -m R -m , wherein R bit radix, R n- bits right.
II. Hex conversion
① binary to decimal conversion Binary -> decimal
And adding by weight: part before the decimal point, and finally a integer from right to left beginning, sequentially from 0 to bit n, successively adding multiplied by 2 ^ n; fractional part calculated from left to right, l, 2,3 ...... sequentially counted as the first n bits, the bit n multiplied by 2 -n power, can be obtained by adding the decimal number of decimal places.
② binary converted to hexadecimal
Each binary number corresponds to a four digit hexadecimal to decimal as the boundary, the integer part of each four spaced from right to left, left up less than 0 to 4; fractional part of a binary number from left to right per 4 bit apart, the right complement of less than 4 0 can be obtained by hexadecimal
③ converted into binary Decimal
In the limit of a decimal point, with the integer part made modulo 2 addition, with the fractional part is rounded by Method 2: first by two and obtain the calculation result to the integer part, the fractional part of the result is multiplied by 2 again, until the fractional part 0 is far, the first obtained as a binary integer part of the highest decimal, integer part of the subsequent turn arranged to obtain binary fractional part.
Floating-point operations the computer is inaccurate: some decimal decimal not accurately represented in binary, in line with a certain degree of accuracy, the tail can be discarded
④ decimal converted to hexadecimal
And converted to binary Similarly, the integer part is modulo 16 addition method, the fractional part is rounded by Method 16
⑤ converted into a binary hex
Convert binary to hex the reverse process, each corresponding to 4 hexadecimal to binary, bit by bit to expand
⑥ hexadecimal to decimal conversion
Binary to decimal conversion and the like, according to the right to add method, the integer N multiplied by the power portion 16 sequentially, -n power multiplied by the fractional part 16, the addition can be
III. Summary
1. Other decimal binary switch: by weight and adding
2. Other transfer Decimal Hex: modulo addition method +-yl group by rounding method
3. The binary and hexadecimal transformed into each other: 4 respectively before and after the integer part of the conversion 4