Decimal to binary and hex calculator

Category: Web


(1) Decimal conversion to binary, divided into integer part and fractional part

1 integer part

Method: Except for the 2 remainder method, that is, each time the integer part is divided by 2, the remainder is the number on the bit weight, and the quotient continues to divide by 2, and the remainder is the number on the previous bit weight. This step continues. Until the quotient is 0, the last reading is read from the last remainder, up to the first remainder. Here's an example:

Example: Converting decimal 168 to binary

Get the result Convert the decimal 168 to binary, (10101000) 2

Analysis: In the first step, divide 168 by 2, quotient 84, and the remainder is 0.

In the second step, the quotient 84 is divided by 2, and the quotient 42 is 0.

In the third step, the quotient 42 is divided by 2, and the quotient 21 is 0.

In the fourth step, the quotient 21 is divided by 2, and the quotient 10 is 1.

In the fifth step, the quotient 10 is divided by 2, and the quotient 5 remainder is 0.

In the sixth step, the quotient 5 is divided by 2, and the quotient 2 remainder is 1.

In the seventh step, the quotient 2 is divided by 2, and the quotient 1 remainder is 0.

In the eighth step, the quotient 1 is divided by 2, and the quotient 0 remainder is 1.

The ninth step, the reading, because the last digit is obtained by dividing by 2 multiple times, so it is the highest digit, and the reading number is read forward from the last remainder, ie 10101000.

(2) Fractional part

Method: Multiply 2 by the whole method, multiply the fractional part by 2, then take the integer part, and the remaining fractional part continues by 2, then take the integer part, and the remaining fractional part is multiplied by 2, all the way The fractional part is zero. If it can never be zero, it is the same as the rounding of the decimal number. When the number of decimals is kept as required, it is rounded off according to whether the latter digit is 0 or 1. If it is zero, it is rounded off. If it is 1, it is rounded up. In other words, it is 0 rounds and 1 entry. The reading should be read from the previous integer to the following integer. Here is an example:

Example 1: Convert 0.125 to binary. Result: Convert 0.125 to binary (0.001) 2

Analysis: In the first step, multiply 0.125 by 2 and get 0.25, then the integer part is 0 and the fractional part is 0.25.

In the second step, multiply the fractional part by 0.25 by 2 to obtain 0.5, then the integer part is 0 and the fractional part is 0.5;

In the third step, multiply the fractional part by 0.5 by 2 to obtain 1.0, then the integer part is 1, and the fractional part is 0.0;

In the fourth step, the reading, read from the first position, reads the last one, which is 0.001.

Example 2, convert 0.45 to binary (retained to the fourth decimal place)

As you can see from the above steps, when the fifth multiplication is done, the result is 0.4, then the fractional part continues to multiply by 2, which is 0.8, 0.8 is multiplied by 2, and it is impossible to multiply by 1.6. The fractional part is zero, so at this time, we have to learn the decimal method to round off, but the binary has only 0 and 1 two, so there is 0 round 1 input. This is also the computer will produce errors in the conversion, but because of the large number of reserved bits, the precision is very high, so it can be ignored.

Then, we can conclude that the conversion of 0.45 to binary is equal to 0.0111

The method described above is a method of converting decimal to binary. Everyone needs to pay attention to:

1) Convert decimal to binary, you need to divide into two parts of integer and decimal respectively.

2) When converting integers, use 2 to take the remainder method, and when converting decimals, use the 2 to take method

3) Pay attention to their reading direction

Therefore, from the above method, we can get the decimal number 168.125 converted to binary 10101000.001, or the decimal number converted to binary number is equal to 10101000.0111.

(3) Convert binary to decimal, not divide the integer and fraction

Method: Add by weight, that is, multiply the number on each bit of the binary by the weight, and then add the sum is the decimal number. The example converts the binary number 101.101 into a decimal number.

The result is: (101.101) 2 = (5.625) 10

Everyone is doing binary conversion to decimal.

1) To know the weight of each bit of the binary

2) To be able to find the value of each bit

Conversion code chart
Decimal 0 1 2 3 4 5 6 7
Hexadecimal 0 1 2 3 4 5 6 7
Binary 0000 0001 0010 0011 0100 0101 0110 0111
Conversion code chart
Decimal 8 9 10 11 12 13 14 15
Hexadecimal 8 9 A B C D E F
Binary 1000 1001 1010 1011 1100 1101 1110 1111

 

    Sign in for comments!
Comment list (0)

Powered by TorCMS (https://github.com/bukun/TorCMS).