Base conversion with the original code, anti-code complement and frameshift

Understand, adorable new big brother seek correction!

1. Base conversion
ten revolutions two: for example, 127: 2 | 1111111 127 -----. 1
2 |. 1 ----- 63 is
2 |. 1 ----- 31 is
2 | ------ 15. 1
2 | --------. 7. 1
2 | --------. 3. 1
. 1 | --------- 0. 1
converts binary numbers into decimal numbers R is generally used to conduct on-press law. For the specific mode of operation: the value of each R-nary number represented by Rk form, i.e. base number is a power of R, index k, k and a distance between the bit and the decimal point related. When this bit to the left of the decimal point, k is a value between the number of digital bits and the decimal point, and when the bit is located to the right of the decimal point, k is a negative value whose absolute value is between the number of digital bits and the decimal point plus 1. (Can not read anyway)

II to 8 mils, for example, ten 1010101001 * 2 + 2 * 1 6 tight adhesion 1 + 4 * 2 * 1 + 2 m 2 = 340 256 + 64 + 16 + 4 = 340

The most commonly used is "divided by R modulo Law"


Binary octal: Convert every three binary number to octal; Binary hex: converts every four binary number to octal; octal transfer binary: convert each octal number to three binary numbers; turn hex binary: convert each hexadecimal number of 4-bit binary number. The above are converted to decimal point as a starting point to calculate the number of digital. Octal and hexadecimal number conversion can be converted to a binary number, and then converted to the target hex. (I have not tried, feeling very complicated)

2. The original code, anti-code, complement, shift
the original code
the most significant bit position only a first sign bit (0 positive, 1 negative), an absolute value representation of the value itself to rest of the delegates. (7 bits in the form of their understanding, 8 bits plus sign, binary number)
as the original code +1 00000001-1 original code of the original code 10000001 +2 00000010-- 2 1000 0010 primitive
operation It is wrong as (00000001) 2 + (1000 0001) 2 = (10000010) = 21 + -2 -1

Anti-code
number of positive anti-code the same as the original code. Inverted negative sign bit is 1, the number of remaining bits for the absolute value of the original code bitwise. This process makes negated this coding is called "inverted."
-1 inverted 11111110-2 inverse code 11111101

Wrong calculation concept (00000001) 2 + (11111110) 2 = (11111111) 2 -1 = 1 + -0

Complement
positive numbers complement to the original codes are the same. Negative complement is the anti-code plus 1, plus 1 this is "up."
Complement 1111 1111 -1 -2 inverted 11111102
complement can calculate the correct result
(00000001) 2 + (1111 1111) 2 = (0000 0000) 1 + 2 -1 = 0

Frameshift
shift is a coding of the sign bit inverted code obtained. Frameshift only for representing floating-point exponent, so only for integers.
-1 frameshift 01111111-2 frameshift 011111011 frameshift 1000 0001

The above operation ignorant of it? Every binary a binary.

It seems to have seen the floating-point calculations that can not read! ! ! ! !

 

Guess you like

Origin www.cnblogs.com/xuzhiwen/p/11112203.html