如何将十进制转换为十六进制?
数字系统是表示数字的系统。数字系统中有不同类型的表示。它们是二进制 (Base – 2)、十进制 (Base – 10)、八进制 (Base – 8) 和十六进制 (Base – 16)。
十进制到十六进制转换是将十进制数转换为十六进制数的过程。十进制数的基值为 10(0 到 9),十六进制的基值是 16(0 到 9 和 A 到 F,10-15)。
下表显示了十六进制、十进制和二进制值的表示:Hexadecimal Digit Decimal Digit Binary Form 0 0 0000 1 1 0001 2 2 0010 3 3 0011 4 4 0100 5 5 0101 6 6 0110 7 7 0111 8 8 1000 9 9 1001 A 10 1010 B 11 1011 C 12 1100 D 13 1101 E 14 1110 F 15 1111
有多种方法可以将十进制数转换为十六进制数。它们如下:
用整数部分转换数字
Step 1: Take the decimal number as dividend and 16 as the divisor (hexadecimal number will have 16 as a base)
Step 2: Divide the dividend with the divisor and store the remainder in an array
Step 3: Now divide the quotient obtained from the above step by 16 and store the remainder in the array.
Step 4: Repeat the third step until the number is greater than zero.
Step 5: The final hexadecimal value will be the reverse order of the array.
示例 1:让我们考虑一个十进制数 450。我们需要将此十进制数转换为十六进制数。
解决方案:
Given: Decimal number = 450(10)
Step 1: 450/16 gives Q1 = 28 and R1 = 2
Step 2: 28/16 gives Q2 = 1 and R2 = 12 = C
Step 3: 1/16 gives Q3 = 0 and R3 = 1
Step 4: 0/16 gives Q4 = 0 and R4 = 0
Therefore, the hexadecimal value is 01C2(16)
示例 2:将 6096 (10)转换为 ________ (16)
解决方案:
Given: Decimal number = 6096(10)
Step 1: 6096/16 gives Q1 = 381 and R1 = 0
Step 2: 381/16 gives Q2 = 23 and R2 = 13 = D
Step 3: 23/16 gives Q3 = 1 and R3 = 7
Step 4: 1/16 gives Q4 = 0 and R4 = 1
Step 5: 0/16 gives Q5 = 0 and R5 = 0
Therefore, the hexadecimal value is 017D0(16) or 17D0(16)
用小数部分转换数字
Step 1: Take the decimal fractional number and multiply it with 16 (hexadecimal number will have 16 as a base)
Step 2: Store the remainder in an array i.e. the integer part
Step 3: Repeat the above two steps until the number is zero.
Step 4: The final hexadecimal value will be the elements of the array.
示例 1:将 0.0568 (10)转换为 _______ (16)
解决方案:
Given: Decimal number = 6096(10)
Step 1: 0.0645 x 16 = 1.032 and R1 = 1
Step 2: 0.032 x 16 = 0.512 and R2 = 0
Step 3: 0.512 x 16 = 8.192 and R3 = 8
Step 4: 0.192 x 16 = 3.072 and R3 = 3
Step 5: 0.072 x 16 = 1.152 and R3 = 1
The fractional part is still not zero so it continues, now we can take up to 5 remainders
Therefore, the hexadecimal value is 0.10831…(16)
用整数和小数部分转换数字
整数部分和小数部分的步骤都要遵循。
示例 1:将 256.00390625 (10)转换为 _________ (16)
解决方案:
Given: Decimal number = 256.00390625(10)
Let’s perform the conversion on integer part:
Integer value = 256(10)
Step 1: 256/16 gives Q1 = 16 and R1 = 0
Step 2: 16/16 gives Q2 = 1 and R2 = 0
Step 3: 1/16 gives Q3 = 0 and R3 = 1
Let’s perform the conversion on fractional part:
Fractional value = 0.00390625(10)
Step 1: 0.00390625 x 16 = 0.0625 and R1 = 0
Step 2: 0.0625 x 16 = 1.0 and R2 = 1
Step 3: 0.0 x 16 = 0 and R3 = 0
Therefore, the hexadecimal value is 100.010(16)
间接转换
在这种类型的转换中,我们将十进制数转换为二进制数或八进制数,并通过对数字进行分组进一步将其转换为十六进制数。
示例 1:将 66 (10)转换为 _______ (16)
解决方案:
Given: Decimal Number = 345(10)
Convert the given decimal number to its binary form:
Binary Number = 1000010(2)
Now, Group 4 binary digits as one group and write its hexadecimal value
i.e. 0100 0010
Therefore, Hexadecimal Number = 42(16)