Conversion between hexadecimal

Source: Internet
Author: User

1) convert decimal to other hexadecimal notation: Use the inverted remainder notation

Example 1: convert a decimal number 89 to a hexadecimal number

89/5 = 17 + 4, and the remainder is 4

17/5 = 3 + 2, and the remainder is 2

3/5 = 0 + 3, and the remainder is 3

Then, if the number of the five-digit system is 324, the remainder should be written in reverse order.

In turn, the calculation is:

4*5 ^ 0 + 2*5 ^ 1 + 3*5 ^ 2 = 89

 

Example 2: Convert decimal 957 to hexadecimal number

957/16 = 59 + 13, the remainder is 13, that is, d

59/16 = 3 + 11, the remainder is 11, that is, B

3/11 = 0 + 3, and the remainder is 3

Therefore, the hexadecimal number is 3bd.

In turn, the calculation is:

D * 16 ^ 0 + B * 16 ^ 1 + 3*16 ^ 2 = 13*16 ^ 0 + 11*16 ^ 1 + 3*16 ^ 2 = 957

 

(2) The conversion between the other two hexadecimal systems requires the use of decimal

For example, convert the octal number 23760 to the hexadecimal number.

First, convert the octal number to the decimal number:

23760 = 2*8 ^ 4 + 3*8 ^ 3 + 7*8 ^ 2 + 6*8 ^ 1 + 0*8 ^ 0 = 10224

Then convert the decimal number to the 7th number using the inverted remainder decimal number to 41544.

 

Conversion between hexadecimal

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.