Decimal to Binary and Hexadecimal Calculator

Value:
Binary:
hexadecimal:

(1) Convert decimal to binary and divide it into integer part and decimal part

① Integer part

Method: Divide by 2 and take the remainder method, that is, each time the integer part is divided by 2, the remainder is the number on the position, and the quotient is divided by 2 again, the remainder is the number on the previous position, and this step continues until the quotient is 0. When reading the last number, read from the last remainder to the first remainder. The following is an example:

Example: Convert decimal 168 to binary

The result is to convert the decimal 168 into binary, (10101000)2

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

The second step is to divide the quotient 84 by 2, the quotient 42 has a remainder of 0.

The third step is to divide the quotient 42 by 2, the quotient is 21 and the remainder is 0.

Step 4: Divide the quotient 21 by 2, the quotient is 10 and the remainder is 1.

Step 5. Divide the quotient 10 by 2. The quotient 5 has a remainder of 0.

Step 6. Divide the quotient 5 by 2, the remainder of the quotient 2 is 1.

Step 7. Divide the quotient 2 by 2, the remainder of the quotient 1 is 0.

Step 8. Divide the quotient 1 by 2, the quotient is 0 and the remainder is 1.

Step 9: Read the number. Since the last digit is obtained by dividing by 2 multiple times, it is the highest digit. Read the number from the last remainder forward, i.e. 10101000.

(2) Decimal part

Method: Multiply by 2 and round up, that is, multiply the decimal part by 2, then take the integer part, continue to multiply the remaining decimal part by 2, then take the integer part, and multiply the remaining decimal part by 2 again, and continue to round up until the decimal part is zero. If it can never be zero, it is the same as rounding a decimal number. When the number of decimal places is required to be retained, it is determined according to whether the last digit is 0 or 1. If it is zero, discard it, and if it is 1, add one digit. In other words, round 0 and add 1. Read the number from the first integer to the last integer. The following example:

Example 1: Convert 0.125 to binary and get the result: Convert 0.125 to binary (0.001)2

Analysis: The first step is to multiply 0.125 by 2 to get 0.25, so the integer part is 0 and the decimal part is 0.25;

The second step is to multiply the decimal part 0.25 by 2 to get 0.5, so the integer part is 0 and the decimal part is 0.5;

Step 3, multiply the decimal part 0.5 by 2 to get 1.0, then the integer part is 1 and the decimal part is 0.0;

The fourth step is to read the numbers from the first digit to the last digit, which is 0.001.

Example 2: Convert 0.45 to binary (to the fourth decimal place)

As you can see from the above steps, when you do the multiplication for the fifth time, the result is 0.4, then the decimal part is multiplied by 2 to get 0.8, 0.8 is multiplied by 2 again, and it is impossible to get a zero decimal part in the end. Therefore, at this time, you have to learn the decimal method to round off, but there are only two binary numbers, 0 and 1, so 0 is rounded to 1. This is also an error in the conversion of the computer, but because there are many bits retained and the accuracy is very high, it can be ignored.

So, we can conclude that converting 0.45 to binary is approximately equal to 0.0111

The method described above is the method of converting decimal to binary. What you need to pay attention to is:

1) To convert decimal to binary, you need to separate the decimal into two parts and convert them separately.

2) When converting integers, the remainder method is used, while when converting decimals, the multiplication by 2 method is used.

3) Pay attention to the direction they read

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

(3) Converting binary to decimal does not distinguish between integer and decimal parts.

Method: Use the weighted addition method, that is, multiply each digit of the binary number by the weight, and then add them together to get the decimal number. Example: Convert the binary number 101.101 to a decimal number.

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

What you need to pay attention to when converting binary to decimal is

1) Know the weight of each bit in binary

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