Hexadecimal conversion, hexadecimal to hexadecimal

Source: Internet
Author: User

Hexadecimal conversion, hexadecimal to hexadecimal

I. Numerical and numeric Conversion

(1) Number System

Binary is used in computers, because binary is easy to operate, easy to implement, and reliable, providing a favorable way for logical design and saving devices. Generally, carry is used for counting:

When N goes into one place, N indicates the number of symbols required by a single digit as the base.

Binary: Two-to-one, one-to-two

Gossip: Every eight to one, borrow one as eight

Hexadecimal format: The hexadecimal format is used for each heap and the hexadecimal format is used as the hexadecimal notation.

(2) Digital Conversion

Conversion principle: When the conversion between different carry counting systems is based on the principle that two rational numbers are equal, then the integers and scores of the two numbers must be equal, that is, the first two numbers are equal, after conversion, it must be equal.

Decimal: 10 Base numbers: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Binary: has two bases: 0, 1

Octal: Eight bases: 0, 1, 2, 3, 4, 5, 6, and 7

Hexadecimal: there are 16 bases: 0-9, A, B, C, D, E, F (A = 10, B = 11, C = 12, D = 13, E = 14, F = 15)

Ii. Conversion between decimal and other hexadecimal

(1) decimal and binary

(1) decimal-binary (operator complement)

Divide the decimal number by 2. If the value is 0, the remainder is written in the inverse direction, that is, the binary number.

For example, the quotient obtained by dividing 36 by 2 is 18 9 4 2 1.

The remainder is 0 0 1 0 0 1

Write the remainder from right to left: 1 0 0 1 0 0

The resulting 100100-bit binary number

(2) binary-decimal

Calculation formula: a * 20 + B * 21 + c * 22 +... + m * 2 (n-1) =

In the preceding formula, a indicates the first digit on the right of the binary number, and B, c,..., and m.

For example, 1011001 is changed from right to left to 89 in decimal format.

1*20 + 0*21 + 0*22 + 1*23 + 1*24 + 0*25 + 1*26

= 1 + 8 + 16 + 64

= 89

TIPS: To facilitate calculation, you can change the formula to the following format: (Note: This tips are only applicable to computation of smaller numbers)

Binary right digit count

1

2

3

4

5

6

7

8

10jin

Number

1

2

4

8

16

32

64

128

Formula prototype

20

21

22

23

24

25

26

27

(2) decimal and octal

(1) decimal-octal

The decimal number is divided by 8 sequentially until the quotient is 0. The remainder is written in the reverse order, that is, the octal number. (Same Decimal-binary)

(2) octal -- decimal (same binary -- decimal)

Calculation formula: a * 80 + B * 81 + c * 82 +... + m * 8 (n-1) =

TIPS:

N digits from the right

8

7

6

5

4

3

2

1

8 (n-1)

87

86

85

84

83

82

81

80

Actual number in decimal format

2097152

262144

32768

4096

512

64

8

1

(3) decimal and hexadecimal

(1) decimal-hexadecimal

Divide the decimal number by sixteen,

0, 1, 2, 3, 4, 6, 7, 8, 9, A (10), B (11), C (12), D (13), E (14), F (15)

The decimal number is divided by 16 one by one until the quotient is 0. The remainder is written in reverse order, that is, the hexadecimal number. (Same Decimal-binary)

For example, the remainder obtained by dividing 75 by 16 is 11 (B) 4.

The remainder is written from right to left as 4B (16)

(2) hexadecimal -- decimal (same binary -- decimal)

Calculation formula: a * 160 + B * 161 + c * 162 +... + m * 16 (n-1) =

TIPS:

163

162

161

160

4096

256

16

1

Iii. Conversion between other hexadecimal formats

(1) binary and octal

(1) binary conversion to octal

For integers, each group of three digits is used from left to right. If there are less than three digits, 0 is added on the left. Each group is individually converted to an octal number.

Example: (001 101 111 011)

1 5 7 3

Therefore, (1573) is the resulting octal number.

(2) convert octal to binary

Replace each octal value with three binary values to complete the conversion.

Example: (1 7 3 5)

001 111 011 101

Therefore, (1111011101) is the binary number.

(2) binary and hexadecimal

(1) convert binary to hexadecimal

Each four digits of the binary number are represented by a hexadecimal number. The integer part is converted from the right to the left to a group of four decimal points, the decimal part is converted from the decimal point to the right by a group of four digits.

Example: (1001 0111 0111 1001)

9 7 7 9

Therefore, (9779) is the hexadecimal number.

(2) hexadecimal conversion to binary

Each hexadecimal number is represented by four binary numbers.

Example: (8 7 6 5)

1000 0111 0110 0101

Therefore, (1000011101100101) is the binary number.

In summary, decimal can be converted to binary, octal, and hexadecimal, and binary can be converted to octal and hexadecimal.

Related Article

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.