Binary, original code, complement, anti-code
1. Four kinds of binary
1 (on), 0 (off) consists of a binary data: 1 bit (bit).
1 byte=8 bit, 1 k=1024 byte, 1 m=1024 k, 1 g=1024 m, 1 t=1024 G.
Binary: 0, 1 composition, with "0b" beginning.
Octal: 0, 1, 2, 3, 4, 5, 6, 7, starting with "0".
Decimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, default decimal.
Hex: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, starting with "0x".
2. Convert the other binary to decimal
Binary---decimal: Each number itself is a power of (n-1), such as: 0b101=1*2^2+0*2^1+1*2^0=5.
Octal decimal: Each digit itself *8 (n-1) power, such as: 0101=1*8^2+0*8^1+1*8^0=65.
hexadecimal---decimal: Each digit itself *16 (n-1) power, such as: 0x101=16*2^2+8*2^1+1*8^0=257.
hexadecimal letters correspond to numbers: A (10), B (11), C (12), D (13), E (14), F (15).
3, decimal to other binary
Decimal---binary: The decimal number is divided by 2, except for quotient 0, which combines the remainder from backward forward, such as: 5 = (5/2=2 "1") = (2/2=1 "0") = (1/2=0 "1") =0b101.
Decimal---octal: The decimal number is divided by 8, except for quotient 0, which combines the remainder from backward forward, such as: 65 = (65/8=8 "1") = (8/8=1 "0") = (1/8=0 "1") = 0101.
Decimal---16 binary: The decimal number is divided by 16, except for quotient 0, the remainder is combined from the backward, such as: 257 = (257/16=16 "1") = (16/16=1 "0") = (1/16=0 "1") =0x101.
4, 8421 Law:
Binary: 1, 1, 1, 1, 1, 1, 1, 1
Decimal: 128, 64, 32, 16, 8, 4, 2, 1
Binary---decimal: 1 The corresponding location data is added directly, for example: 0b101=4+1=5.
Decimal---binary: Starts from 128 in descending order, the last left complement, such as: 5 = (5-4=1 "4,1") =0b101.
5, split the group legal:
Binary, octal: Starting from the right three-bit group, not enough to the left to fill the spirit, directly converted into decimal, grouped together, such as: 0b1101101= "001, 101, 101" = "1, 5, 5" = 0155.
Binary, 16 binary: Starting from the right 4-bit a group, not enough left to fill the spirit, directly converted into decimal, combined, such as: 0b1101101= "0110, 1101" = "6, 13" =0x6d.
6, the original code, anti-code, complement
All the data in the computer is performed in the complement.
The original code: is the binary notation, the highest bit (left) is the sign bit, "0" represents a positive number, "1" for negative numbers, such as: 7 of the original code is 00000111,-7 the original code of 10000111.
Anti-code: The inverse code of positive number is the same as the original code, negative inverse code is the original code "sign bit" other than the inverse (0, 1 interchange), such as: 7 of the anti-code for the 00000111,-7 of the anti-code of 11111000.
Complement: The complement of positive number is the same as the original code, the complement of negative number is its inverse code of the bottom (right) plus 1, such as: 7 of the complement of 00000111,-7 's complement is 11111001.
Older Dick Silk Self-study note--java 0 basics to rookie--006