1. The commonly used numbering
Decimal 0~9
Octal 0~7
Binary 0~1
Hex 0~f
2. Decimal to each of the binary
Method: Divide by the base to take the remainder inverse
3. 2 binary 8 binary 16 decimal
Binary
___________________________
2^3 2^2 2^1 2^0
1 0 0 1 X
=8+ 1 = 9
Octal
———————————--------------
8^1 8^0
1 7
=1*8 + 7*1 = 15
hexadecimal is similar.
4. Binary to hexadecimal octal
Two-turn eight
Three bit a set of results and together
Two-turn 16
Four-bit a group of results are merged together
5. Integer in-memory storage, using a binary
Sign bit
Original code Positive 0
Negative 1
Inverse code positive is the same as the original code
Negative numbers on the basis of the original code, the sign bit is unchanged, the individual bits take the inverse
Positive complement and same source code
Negative number on the basis of anti-code, the sign bit unchanged, the last +1
Case ↓↓↓↓↓↓
————————————————————————————
Original code anti-code complement
5 0000 0101 0000 0101 0000 0101
-5 1000 0101 1111 1010 1111 1011
6. Machine number and truth value
Use the "+", "-" plus the absolute value to denote the size of the value, in this form the value is called "truth" in the computer
After the symbol is digitized, the highest bit "0" of the binary number represents a positive sign, and "1" represents the minus, and the value represented in this form is called the "number of machines" in the computer.
Number of machines decimal points implied non-placeholder
Number of machines signed pure integer points after the lowest bit
The pure decimal point precedes the sign bit, the highest bit.
Unsigned pure integer points after the lowest bit
Pure decimal point before the highest bit
7. Storage of decimals
The small number of computers is stored in binary (floating point) format.
The first is a decimal decimal form, converted into a binary calculation case.
————————————————————————————————
0.8125 converting to Binary
In fact, this situation is who happened to get an exact value.
————————————————————————————————
But for some special cases, that's it.
8. causes of error in floating-point numbers
There are two conditions, which can cause errors.
1) to save the floating-point number in binary, so some decimal places of the original finite bit, according to the above method operation, may become an infinite loop of decimals.
————————————————————————————————
(decimal) 0.9 turns into 2 binary is infinite loop decimal 0.1110011001100110011 ...
————————————————————————————————
2) The computer has limited precision in saving floating-point numbers, for example, float can retain a decimal number of up to 7 bits (binary 23-bit) valid digits, and a double can retain the decimal 15~16 bit (binary 52-bit) valid digits. The valid number is ignored.
Why do decimals have errors in the computer? Some problems about machine number, code system, floating point numbers, and numbers conversion