Directory structure:
contents Structure [-]
- Why computer code requires 2 binary representation
- The relationship between the original code, the inverse code and the complement
- Why you need anti-code, complement
- Conversion of the binary system
- Conversion between decimal and binary binary
- Binary and binary conversions
- Conversion of hexadecimal and binary binary
- The range of data that a byte can represent
1, why the computer code needs to be represented by 2 binary
We all know that our skilled mechanism is the decimal, that is (0 to 9), every 10 into 1. If you want your computer to use decimal, first of all, you should allow your computer to recognize 10 numbers. It is generally considered that 10 digits are identified by the voltage level in the component. If the maximum voltage is 10V, then each digital ID is 1V, the result is that each digital voltage is easy to receive external voltage interference. In addition to this problem, there is a bigger problem, that is, if the hardware to identify the 10 state, its circuit structure will be very complex.
Since the binary number is only 2 digital, the circuit is simple because there are only two components in a stable state. The following advantages are mainly in binary system:
* Simple Arithmetic rules
* Suitable for logical operation
* Easy to convert
* Strong anti-jamming ability
2, the relationship between the original code, anti-code, and complement
First need to know that the computer's code is complementary, positive the original code, anti-code and complement are the same, the complement of negative numbers is the original code according to the counter to get anti-code and then add 1.
Like what:
1 The original code is: 00000001
1 The anti-code is: 00000001
The 1 complement is: 00000001
-1 of the original code is: 10000001
-1 of the anti-code is: 11111110
-1 of the complement is: 11111111
2.1 Why you need anti-code, complement
There is no subtraction, multiplication, division operation in the computer, which is implemented by addition. For example, by 1+ (-1) to achieve subtraction.
Do not use anti-code and complement:
3-2=3+ (-2) =0000 0011+1000 0010=1000 0101=-5
Obviously the result is not correct.
Using the inverse code does not use the complement:
3-2=3+ (-2) =0000 0011+1111 1101=1 0000 0000=0
Here the result of the binary has 9 bits, if we just consider 8 bits, then the result is taken back 8 0, conversion bit decimal is 0.
Use anti-code with complement
3-2=3+ (-2) =0000 0011+1111 1110=0 0000 0001=1
3, binary Conversions 3.1 decimal and binary conversions
decimal-to-binary rule: The integer part is in addition to 2 of the remainder, in reverse order. The decimal part is divided by 2 rounding, and the sequence is ordered.
For example
A number: 15.4
The whole number of parts is divided into: 0000 1111.
The number of decimal parts is divided into:
0.4*2=0.8 rounding is more than 0 0.8
0.8*2=1.6 Rounding is more than 1 0.6
0.6*2=1.2 Rounding is more than 1 0.2
...........
Keep two decimal places, then 01
The 15.4 binary is 0000 1111.01 and can be verified by an on-line binary converter
Binary to decimal rule: Press the right to expand to add.
For example
Some binary: 0000 1111
Convert to decimal: 1*2^ (0) +1*2^ (1) +1*2^ (2) +1*2^ (3) +0*2^ (4) +0*2^ (5) +0*2^ (6) +0*2^ (7) =15
3.2 Octal and binary conversions
octal to binary rules: "One to three bits";
Binary to octal rule: "Three bits in one place";
3.3 Conversion between hexadecimal and binary
Hex-to-binary rule: "One turn four bits";
Binary hex rule: "Four-bit-one";
4, the range of data that a byte can represent
A byte has 8 bits, the highest bit is 0 for a positive number, and a maximum of 1 indicates a negative number.
So:
The positive range of a byte is "0000 0000"-"0111 1111", and the conversion to decimal is "0"-"127".
A byte of negative range "1000 0000"-"1111 1111", converted to decimal is "-128"-"-1".
So the data range "-128"-"127" can be represented.
"Java Learning" in the system