1.3 "number" of experience
The data recovery process, which is a process to deal with the number. In this, we need to introduce some of the basics about the numbers.
1.3.1 Number System
Number system, that is, we often say that the binary, octal, decimal, hexadecimal, and so on. In the data recovery process, often encounter different forms of numbers. Because computers use binary, when we see the use of disk-editing software is hexadecimal, and most of us are accustomed to decimal. Here, we do all kinds of number system with a simple introduction.
1 Decimal
In our daily lives, which means that the number of methods as "decimal", that is, every decimal, hexadecimal 10 using ten digits: 0,1,2,3,4,5,6,7,8,9 . Decimal suffix d said, but under normal circumstances would be omitted.
2 Binary
For a computer, it recognizes only the "0" and "1", which is "binary", every binary. Binary using only two digits 0 and 1, each 0 or 1 is called a "bit (bit)", each 8 "bit" form a "byte (byte)". B represents the binary suffix such as 110b.
However, in practice, the length of the binary writing is a very troubling thing, so they introduced the octal and hexadecimal. Because the band bigger number expressing the length of the shorter. The reason that the "octal" and "Hex" because "8" and "16" are the "power of 2 3" and "4 power of 2", which makes the three-band Conversion between very direct. Octal, hexadecimal or binary shortened, while maintaining the characteristics of the expression of binary numbers. In practice among data recovery, we used to be in hexadecimal, so this only describes hexadecimal, octal and no longer introduced.
3 hex
Hex is every 16 into one, but we only have ten digits from 0 to 9, so we use A, B, C, D, E, F (Letters are not case-sensitive) six letters to represent 10 respectively , 11,12,13,14,15. That is, of hex 0,1,2,3,4,5,6,7,8,9, A, B, C, D, E, F which sixteen digits. Hex suffix H said that if 872H indicates that this is a hexadecimal number, it can be represented as 0x872, in this book, we use a representation.
1.3.2 Conversion between number system
Number system is not enough just to know, because in practical applications often need to convert between them accordingly, and now we have to introduce the number system conversion methods between.
1 binary to decimal
Before introducing the binary to decimal, we first look at binary "bit right", as shown in Table 1.1.
Table 1.1 binary bit weights
Median N
|
...
|
3
|
2
|
1
|
Bit right
|
...
|
2 2
|
2 1
|
2 0
|
You can see that the first bit position N is N-1 right to a power of 2. In the binary to decimal when translated, is multiplied by the value of each bit of it right, then all the products are summed. Such as:
10101011b 1 × 2 = 0 1 × 2 + 1 × 2 + 0 2 + 1 2 × 3 × 2 + 0 4 2 + 1 × 5 × 2 + 0 6 2 + 1 × 7 = 171
2. Hex to decimal
When converting hex to decimal, binary conversion to the same principles and decimal, but the base 16 can be replaced. Note that, in hexadecimal, and washed successively with 10 to 15 A, B, C, D, E, F represents, in the event A ~ F character, the character is required during operation to replace it expression of the corresponding number.
Suppose there is a hexadecimal number 0x2AF5, when converted to decimal, the method is:
5 × 16 0 × 16 + F 1 + A × 16 2 + 2 × 16 3 = 10997
3. Decimal to binary conversion
When converting decimal to binary, decimal number by 2, the quotient and remainder; then use the provider as a dividend divided by 2, the quotient and the remainder; divided by 2 ...... then quotient as a dividend until the quotient is 0. Then the remainder when divided by each reverse order, ie, get the binary conversion. Figure 1.8, 6 is converted into binary 110b.
Figure 1.8 decimal to binary
4. Decimal to hexadecimal
When converting decimal to hexadecimal, binary and convert the same way, only 16 can be replaced by the divisor 2. For example, the 130 converted to hexadecimal:
130/16 = I 8 2
8/16 = I 0 8
That is, 130 is converted into hexadecimal result is 0x82.
5 binary, hexadecimal conversion between
Conversion between binary and hexadecimal is more important, the conversion between them is very convenient: the binary number from right to left into a period of every four, the last paragraph if less than four, in its left up 0; then Each segment can be converted to hexadecimal, respectively. For example, when 110101100101001101b converted to hexadecimal, as shown in Table 1.2.
Table 1.2 will 110101100101001101b into hexadecimal
Binary
|
0011
|
0101
|
1001
|
0100
|
1101
|
Hex
|
3
|
5
|
9
|
4
|
D
|
So, 110101100101001101b into hexadecimal value after 0x3594D.
1.3.3 Rounding and take over operation
Rounding means during operation division, the quotient only as a result, part of the remainder is discarded. Rounding operator is "DIV", for example:
512 DIV 510 = 1
Modulo arithmetic means during division, just take the remainder as a result, the quotient discarded. Remainder operator is "MOD", for example:
512 MOD 510 = 2
1.3.4 Number of storage format
The number of store formats, which is stored in the order of numbers. When the value indicates the size of a byte (Byte) maximum can only express to 255 (0xFF), it is not enough. To meet the needs of actual use, typically use two, four, or eight bytes (Byte) to indicate the size of the values. For the case of multi-byte value, there is a sequence of problem. There are two storage order number - Big-endian format and the Little-endian format.
Big-endian : also been translated as "the bulk of the rank." Byte stored sequentially from the highest to the lowest position, high front and low in the post.
Little-endian : also been translated as "head-bit sequence." That byte stored sequentially from the lowest to the highest bit position, low front, high in the post.
For example, there is a hexadecimal number "23 48 BA 4C", using Big-endian format stored in the form of "23 48 BA 4C"; Little-endian format using a file system is stored in the form of "4C BA 4823 ", that low front, high in the post.
|