Software testing study notes: common base and conversion

Common base and conversion

One, common mathematical base

Binary (bin): enter 1 every binary, it only has two bases of 0 and 1 in it [11011]
Octal (oct): enter 1 at every 8th, and its base is 0-7
Decimal (dec): enter every 10 1. The base in it is 0-9
hexadecimal (hex): every 16 enters 1, the base in it is 0-9 ABCDEF

Two, common base conversion

The so-called base conversion means that the numbers expressed in different bases can be converted into each other. For example, decimal 8 can be converted to binary 1000 to represent.

Convert other bases to decimal:

First determine the number of digits of the current number, and then count from right to left, and consider it as low to high.
Write down the number of digits N (N is not a fixed number, determined by the current digit) and
take out each digit The number m above, and then use this m to multiply the current base to the power of N-1. (m is not fixed, it is the number in the current position)
Add the multiplication results of each bit, and the final sum is the decimal value corresponding to the value

Decimal to Binary

Divide this decimal number by 2 to get the quotient and remainder.
Determine whether the quotient is 0. If it is not 0, continue to use this quotient to remove 2
until the end of a certain time when the quotient is 0. Reverse the remainder generated during the division process and arrange the
final The result of the arrangement is the value of the current decimal system converted to binary

8/16 hexadecimal to binary

Convert all "base numbers" in the octal or hexadecimal system to binary. (It should be noted that the octal to binary should be written in three digits, and the hexadecimal should be written in four digits) After the
above binary base conversion, when we get a specific octal or hexadecimal value, we only It needs to be spliced ​​together

Guess you like

Origin blog.csdn.net/m0_51684972/article/details/112297370