Hexadecimal Integers (Cont.)
Converting Unsigned Hexadecimal to Decimal
Weighted positional notation represents a convenient way to calculate the decimal value of an unsigned hexadecimal integer having n
digits:
dec = (Dn-1×16n-1) + (Dn-2×16n-2) + … +(D1×161) + (D0×160)
Each digit Dj
is multiplied by 16j
. For example, the decimal equivalent of the hexadecimal number (B65F)16
can be found from the multiplication of the digits by powers of 16:
16n |
Decimal Value |
|
16n |
Decimal Value |
|
16n |
Decimal Value |
160 |
1 |
|
163 |
4096 |
|
166 |
16,777,216 |
161 |
16 |
164 |
65,536 |
167 |
268,435,456 |
162 |
256 |
165 |
1,048,576 |
168 |
4,294,967,296 |
Converting Unsigned Decimal to Hexadecimal
- Repeatedly divide the decimal value by 16.
- Save each remainder as a hexadecimal digit.
- Collect the hexadecimal digits in the remainder column in reverse order.
“Recognizing power in another does not diminish your own.”
― Joss Whedon
|