Decimal, binary, octal, hexadecimal conversions

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

The decimal number consists of a total of 10 numeric characters in 0~9, 10 in each of the decimal digits, and a maximum number of 9 in each decimal digit.

The binary number consists of 0 and 12 numeric characters, and in binary one, the maximum number is 1 for each bit in the binary.

Octal is composed of a total of 8 numeric characters in the 0~7, "every eight into one" in octal, and the maximum number is 7 in each bit in octal.

Hexadecimal is composed of 0~9, A, B, C, D, E, f a total of 16 characters, in hexadecimal "every 16 in one", in hexadecimal the largest number is F.

First of all, talk about decimal to binary binary:

Example: decimal to go binary

Take 55 divided by 2.

55/2=27 Yu 1, take 27 divided by 2,27/2=13 1, take 13 divided by 2,13/2=6 1, take 6 divided by 2,6/2=3 the remaining 0, take 3 divided by 2,3/2=1 to 1,

Then the decimal 55 is converted to binary is 110111

Decimal Turn octal

Example: decimal 534 turn octal

Take 534 divided by 8,534/8=66 6, 66 divided by 8 equals 8 + 2, 8 divided by 8 equals 1 + 0, then decimal 534 turns octal is 1026.

Decimal Turn hex

Example: decimal 300 turn hex

Take 300 divided by 16 equals 18 + 12 (12 in the 16 binary in C, 10 is a, B is 11, until F is 15), take 18 divided by 16 equals 1 more than 2, take 1 divided by 16, equals 0, do not represent, then decimal 300 is converted to 16 in the result of 12C.

Binary conversion to Decimal

Example: 111=1*4+1*2+1*1=7;

It has a comparison table:

1

1

1

1

1

1

1

1

128

64

32

16

8

4

2

1

See how many bits are in the binary, and then add them apart.

Binary conversion to octal

There is a way to put the number of binary from right to left, three bit a group, not enough to fill 0

Column: 111=4+2+1=7

11001 split into 001 and 011,001=1,011=2+1=3;

Then the 11001 conversion to octal is 31.

Binary conversion to hexadecimal

Reference binary to octal, but it is from right to left, four bit a group, not enough to fill 0

1101101: Split into 1101, 0110

Two binary values are computed separately, 1101=8+4+0+1=13, 13 in hex is D

0110=4+2=6 , then the binary 1101101 conversion to 16 binary is 6D.

octal into binary

From back to front, each digit is converted to three-bit binary by decimal, and the vacancy is 0

7=4+2+1=111:77, split apart

So the octal 77 conversion bit binary is 111111.

Octal into decimal

Sub-clause: 555=5*8 's 2-time Square +5*8 +5=320+40+5=365;

octal conversion bit hex

First, the octal conversion bit 2 is binary, then the binary conversion bit hexadecimal

For example: Octal 721 first converted to binary, take apart

7=111 , 2=010,1=001,

Get 277 binary 111010001, then convert to 16, from right to left, four a group, not enough to fill 0

111010001 to 0001,1101,0001

0001=1 , 1101=8+4+1=13, hexadecimal words, for d,0001=1, then convert to 16 binary is 1D1

16 Binary conversion to binary

Convert each digit to binary, each number four bits, less than four bits, front 0

2=0010,F=15=1111,D=13=1101:2FD, split apart, separate

Then convert to binary to get 1011111101

16 Binary conversion to octal

First convert 16 into binary, (principle a hexadecimal to four bit binary), in the binary conversion into octal, (the principle is from right to left three, not enough to fill 0)

The following: hexadecimal 2FD conversion binary 1011111101, in the binary 1011111101 into octal, from the right to the left, four a split, not enough to fill 0

1011111101 split into 001,011,111,101, calculated separately

001=1 , 011=2+1=3,111=4+2+1=7,101=4+1=5, then the last conversion to octal will get 1375.

16 Binary conversion to decimal

Convert to decimal similar to octal binary

2D=2*16: A +13=2*16+13=45 of the first party

Hexadecimal 2D converted to decimal get decimal 45

Decimal, binary, octal, hexadecimal conversions

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.