Essential for the test: binary, decimal, hexadecimal, and octal Conversion

Source: Internet
Author: User
Tags binary to decimal decimal to binary

 1. Convert decimal to binary

To convert decimal to binary, You need to convert the integer part and the decimal part. The integer is divided by 2, and the quotient is divided by 2. After obtaining 0, you can sort the remainder in reverse order.

The fractional part is multiplied by 2, rounded up, and the fractional part continues to be multiplied by 2, rounded up, And the decimal part ends with 0. Sort the integers in order.

For example, what is the value of decimal number 22.8125 converted to binary?

22/2 11
Remaining 0

11/2 5
Remaining 0

5/2 2
Remaining 1

2/2 1
Remaining 0

1/2 0
Remaining 1

So the binary is: 10110

 

0.8125x2 = 1.625 1.625
Take an integer of 1. The decimal part is 0.625.
0.625x2 = 1.25 1.25
Take an integer of 1. The decimal part is 0.25.
0.25x2 = 0.5 0.5
Take an integer of 0, and the decimal part is 0.5.
0.5x2 = 1.0 1.0 integer 1, decimal part is 0, end

Therefore, the binary value of 0.8125 is: 0.1101.

Therefore, the binary value of decimal 22.8125 is 10110.1101.

 

2. Convert binary to decimal

The basic practice of converting a binary number into a decimal number is to first write the binary number as an expansion of the weighting coefficient, and then sum the values according to the decimal addition Rules. This method is called "adding weights. It is easy to understand. There are just a few more terms.

In turn, we can convert binary to decimal. from right to left, we can multiply each number of binary by the corresponding power of 2 (remember that the power starts from 0 ), then, all the results are added to obtain the final result.

For example, how much is the binary 1101 converted to decimal?

 

1011 (2)
= 1*20 + 0*21
+ 1*22 + 1*23
= 1 + 0 + 4 + 8 = 13

 

Therefore, 1101 is converted to 13 in decimal format.

Some simple 2's power still needs to be mastered, so you don't have to remember it. When you use it, check it and remember it several times:

The power 0 of 2 is 1

The power 1 of 2 is 2.

The power of 2 is 4.

The power 3 of 2 is 8.

The power 4 of 2 is 16.

The power 5 of 2 is 32.

The 6th power of 2 is 64.

The 7th power of 2 is 128

The power of 2 is 256

The 9 power of 2 is 512

The 10th power of 2 is 1024

The power of 2's 11 is 2048.

 

3. Binary and hexadecimal conversion

The conversion between the hexadecimal and binary systems is very simple. The hexadecimal to binary system processes every bit of the hexadecimal system as a binary four-bit system. If there are less than four digits, add a zero complement. If binary is converted to hexadecimal, the four bits of binary are processed as one of the hexadecimal values. See the example below:

 

1) convert the hexadecimal number 0209fe83 to 1000001001111111101000 binary

0 0000

2 0010

0 0000

9 1001

F 1111

E 1110

8 1000

3 0011

ABCDE corresponds to 10, 11, 12, 13, 14, 15 in decimal format.

 

2) convert binary number 11010111100010111 to hexadecimal number

Binary Number 11 1010 1111 0001 0111

Hexadecimal number 3
F
1 7

Result: (11010111100010111) 2 = (3af17) 16

 

4. Binary and octal Conversions

The conversion between binary and octal is similar to that between hexadecimal and binary, but only one bit is missing. One octal corresponds to three digits of binary, it is still not enough to use zero-padding before the integer part. The comparison is much simpler. Let's look at the example below:

 

Convert binary 1101100 to octal 154.

 

Binary 001
101 100

Eight shards 1 5 4

 

From the list above, binary is the most important. It is a widely used numeric system in computing technology. It is a conversion between decimal, hexadecimal, octal, and binary, we can use binary as the bridge in the middle, so that the conversion between the other several hexadecimal systems will become easier by using binary as the intermediate key. Of course, these are the basic principles, and we can understand them. The current calculator can easily help us complete the conversion between these hexadecimal values, if we can use a calculator, we still have to choose a calculator without hesitation. That would be fast and accurate.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.