Inter-conversion between the binary systems

Source: Internet
Author: User

The original: The transformation between the binary systems

The conversion between the binaries is as follows:

By the way, there are 12 conversions in the system. Each of the 12 conversion methods is described below

(1) binary into octal

Principle: <1>1 bit octal number can be represented by 3-bit binary digital

<2> with the decimal point: If the left side of the decimal point (that is, the integer part) is not an integer multiple of 3, then the leftmost 0, the right side of the decimal point (that is, the fractional part) should be at the far right of 0

Example: Convert (10.101)2 into octal.

Solution: (1) 3-bit binary complement

namely: (010.101)2

(2) conversion by weight value

(0x22 + 1x21 +0x20). (1x22 + 0x21 +1x20) =2.5

So (010.101) 2 = (2.5) 10

Note: The 3 bits are divided into a group starting from the lowest bit.

(2) binary conversion to decimal

Example: Convert (1101.0101) 2 to decimal.

Solution: 23+ 22+20+2-2+ 2-4=13.3125

So (1101.0101) 2 = (13.3125) 10

Problem-solving skills: Remembering the corresponding bit weights

20 21st 22 23 24 25 26 27 28 29 210 211
1 2 4 8 16 32 64 128 256 512 1024 2048

(3) binary conversion to hexadecimal

Principle: <1>1 digit hexadecimal number can be represented by 4-bit binary digital

<2> with the decimal point: If the left side of the decimal point (that is, the integer part) is not an integer multiple of 4, then the leftmost 0, the right side of the decimal point (that is, the fractional part) should be at the far right of 0

Example: Converting (10.101) 2 to 16-binary.

Solution: (1) complement the binary 3-bit

Get (0010.1010)2

(2) conversion by weight value

21st. (23+21) =2.a

therefore (10.1010)2 = (2. A) 16

Note: The 3 bits are divided into a group starting from the lowest bit.


(4) Octal into binary

Principle: An octal number is divided into three binary numbers, with three-bit binary right add, and finally get binary, the decimal point is unchanged.

Example: Converting (376.01) 8 to binary.

The decomposition diagram is as follows:

therefore (376.01) 8= (11111110.000001) 2

(5) Octal into decimal

Example: Converting (7.44) 8 to decimal

Solution: (7.44) 8 =7x80+4x8-1+4x8-2= (7.5625) 10

Note: The value range of the octal base symbol is: 0~7.

(6) octal conversion to hexadecimal

Here are two solutions:

Solution One: convert octal into binary, then convert binary to hexadecimal

Solution Two: Convert octal to decimal, and then convert decimal to hexadecimal

Example: Converting (67.54) 8 to 16-binary.

Solution One

<1> converting octal to binary

(67.54) 8 = (110111.101100) 2

<2> convert binary to hexadecimal

therefore (110111.101100) 2= (37.B) 16

Solution Two

<1> convert octal to decimal

(67.54) 8 = (55.6875) 10

<2> convert decimal to hexadecimal

therefore (55.6875) 10= (37.B) 16

(7) Decimal conversion to Binary

Integral part---Principle:<1> with 2 In addition to the integer portion of the decimal, taking the remainder of the minimum number of digits

<2> 2 To remove the quotient, take the remainder of the minimum value

<3> repeat <2> until the quotient is 0.

Example: Convert 37 to binary.

Solution: Decomposition as follows

(37) 10 = (100101) 2.

Note: The remainder portion is from low to high, and the written binary is made from high to low.

The---Principle of the remainder part is:<1> by a decimal fraction of 2 times, and the product integers are given the highest

<2> re-use the remaining fractional part by 2, take the product integer to get the sub-high

<3> repeat until the product is 0 or the number of decimal digits that is obtained satisfies the requirement

Example: Convert 0.43 to binary decimal. (assuming that five digits are required after the decimal point)

Solution: As shown

Therefore, the converted binary decimal number is (0.01101) 2

(8) Decimal into octal

Example: Converting (1109) 10 into octal.

Solution: As Solution

So (1109) 10 = (2125) 8

Let's look at the case of converting to octal decimal

For example: (0.385) 10 translates to octal decimal.

Solution: 0.385x8

3 0.08x8

0 0.64x8

5 0.12x8

Results: (0.385) 10 = (0.305) 8

(9) Decimal conversion to hexadecimal

Example: Converting (55.6875) 10 to 16-binary.

Solution:<1> The first part of the small number

10= (PNs )

<2> small number of parts

0.6875x16

11 0

(0.6875) 10 = (0. B) 16

The result is: (55.6875) 10= (37.B)

(10) converting hexadecimal into binary

Principle: A hexadecimal number is decomposed into four-bit binary number, and then the four-bit binary is added by the right, the hexadecimal number is finally obtained, the decimal point is unchanged.

Example: CONVERT (6E.2) 16 to binary.

Solution: The diagram is as follows

The result is: (6e.2) 16 = (01101110.001) 2

(11) hexadecimal conversion to octal

How to solve the problem: first convert hexadecimal to binary, then binary into octal.

Example: CONVERT (8e.09) 16 into octal.

The solution:<1> converts hexadecimal to binary, which is

(8e.09) 16 = (10001110.00001001) 2

<2> binary into octal,

(10001110.00001001) 2 = (216.022) 8

So the final result of the transformation is

(8e.09) 16 = (216.022) 8

(12) hexadecimal conversion to decimal

Example: CONVERT (1a.08) 16 to decimal.

Solution: (1a.08) 16=1x16+10x160+8x16-2= (26.03125) 10

The result is: (1a.08) 16 = (26.03125) 10.

Here, the conversion between the binary has been completed, of course, in the analysis of ideas and examples of the process may have some mistakes. If there is insufficient or need to expand the place also hope that the vast number of friends advice. Also hope to be able to help most friends.

Inter-conversion between the binary systems

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.