Base of hexadecimal conversion

Source: Internet
Author: User
Tags decimal to binary

Basic knowledge

Decimal
The base number is 10, and every 10 goes into 1. In decimal format, a total of 10 different numeric symbols are used. When these symbols are in different positions, their weights are different.

Binary
The base number is 2, and every 2 goes into 1. In binary, 0 and 1 are used.

Octal
The base number is 8, and every 8 to 1. The octal chart uses eight different symbols. Their Conversion Relationship with binary is as follows:

Hexadecimal
The base number is 16, and every 16 to 1. The hexadecimal system uses 16 different symbols. The Conversion Relationship between these symbols and binary is as follows:
A: 1010 B: 1011 C: 1100 D: 1101 E: 1110 F: 1111

Convert to decimal

Decimal
For example, convert the binary number 101.01 to the decimal number.
(101.01) 2 = 1x22 + 0x21 + 1x20 + 0x2-1 + 1X2-2 = (5.25) 10

Decimal
For example, convert octal number 12.6 to decimal number
(12.6) 8 = 1x81 + 2x80 + 6x8-1 = (10.75) 10

Hexadecimal to decimal
For example, convert the hexadecimal number 2AB. 6 to the decimal number:
(2AB. 6) 16 = 2x162 + 10x161 + 11x160 + 6x16-1 = (683.375) 10

Convert to binary

Octal to binary
Rule: in order, each octal number is rewritten to an equivalent three-digit binary number. The order remains unchanged.
Example: (17.36) 8 = (001 111. 011 110) 2 = (1111.01111) 2

Hexadecimal to binary
Rule: The hexadecimal number of each digit is rewritten to the equivalent four-digit binary number, and the order remains unchanged.
Example: (3A8C. D6) 16 = (0011 1010 1000 1100.1101) 2 = (0110) 2

Converts a decimal integer to a binary integer.

Rule: Except for the remainder of the two orders, the number is reversed until the operator is zero.
For example, convert 86 to binary.
2 | 86 ...... 0
2 | 43 ...... 1
2 | 21 ...... 1
2 | 10 ...... 0
2 | 5 ...... 1
2 | 2 ...... 0
2 | 1 ...... 1
Result: (86) 10 = (1010110) 2

Decimal decimal to binary decimal

Rule: Take an integer by two until the decimal part is zero or the given precision.
For example, convert the decimal number 0.875 to the binary number.
0.875
× 2
1.75
× 2
1.5
× 2
1.0
Result: (0.875) 10 = (0.111) 2

Convert to octal

Binary to octal
The integer part starts from the lowest valid bit and is in a group of three digits. If the maximum valid bit is less than three digits, it is filled with 0. Each group can be converted into an octal value, after the conversion is completed, it is an integer of octal.
The fractional part starts from the highest valid bit and is set to three digits. If the lowest valid bit is less than three digits, it is filled with 0. Each group can be converted into an octal value, after the conversion is completed, it is the decimal point of the octal.
Example: (11001111.01111) 2 = (11 001 111.011 110) 2 = (317.36) 8

Hexadecimal to octal
First, convert the hexadecimal format into binary, and then convert the binary format into 8 using the 3 and 1 methods.
Example: (1CA) 16 = (000111001010) 2 = (712) 8
Note: The upper and lower digits before and after the decimal point can be removed.

Decimal octal
Method 1: the division of 8 is used.
For example, convert the decimal number 115 to the octal number.
8 | 115 ...... 3
8 | 14 ...... 6
8 | 1 ...... 1
Result: (115) 10 = (163) 8
Method 2: first use the decimal binary method, and then convert the binary number to the octal number.
Example: (115) 10 = (1110011) 2 = (163) 8

Convert to hexadecimal

Convert binary to hexadecimal
The integer part starts from the lowest valid bits and takes four bits as a group. If the maximum valid bits are less than four bits, it is filled with 0. Each group can be converted into a hexadecimal value, after the conversion is completed, it is a hexadecimal integer.
The fractional part starts from the highest valid bit and takes four digits as a group. If the lowest valid bit is less than four digits, it is filled with 0. Each group can be converted into a hexadecimal value, after the conversion is completed, it is the hexadecimal decimal number.
Example: (11001111.01111) 2 = (1100 1111. 0111 1000) 2 = (CF.78) 16

Octal to hexadecimal
Convert octal to binary, and then convert binary to hexadecimal.
Example: (712) 8 = (111001010) 2 = (1CA) 16

Decimal to hexadecimal

Method 1: Use the except 16 remainder method.
For example, convert the decimal number 115 to the octal number.
16 | 115 ...... 3
16 | 7 ...... 7
Result: (115) 10 = (73) 16

Method 2: Convert decimal to binary, and then convert binary to hexadecimal.
Example: (115) 10 = (1110011) 2 = (73) 16

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.