The Rosetta Stone for Hex to Dec

advertisement
Converting Hex to Dec
By Will Mayall 04-Jan-2012
Contents
Windows Calculator ............................. 1
The Rosetta Stone for Hex to Dec ............... 3
The Rosetta Stone Binary to Hex ................ 5
The Rosetta Stone ASCII to Hex to Symbol ....... 7
Conclusion ..................................... 9
Windows Calculator
First, open a windows calculator and set it to
Programmer’s mode from the View Tab:
1
Type in a Hex 40, then click on the Dec Tab:
2
So a Hex 40 is equal to a Dec 64!
The Rosetta Stone for Hex to Dec
So that was easy, but how do you know the
calculator was correct? Let’s look a little
deeper by comparing a Hex number to a Dec
number.
3
Hex numbers: 0,1,2,3,4,5,6,7,8,9, A, B, C, D, E, F,10,11,12,13,14,15,16,17,18,19
In decimal: 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25
Hex numbers: 1A,1B,1C,1D,1E,1F,20,21,22,23,24,25,26,27,28,29,2A,2B,2C,2D,2E,2F,30
In decimal: 26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48
Hex numbers: 31,32,33,34,35,36,37,38,39,3A,3B,3C,3D,3E,3F,40,41,42,43,44,45,46,47, ...
In decimal: 49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71, ...
Ok, the mystery is solved! As you know, the
decimal system starts at 0 and goes to 9,
accounting for 10 single digit numbers. Hex on
the other hand starts at 0 and goes to F
accounting for 16 single digit values. So there
is a pattern to this maddest! Once a Hex number
gets to the end of the 16th number it starts over
at 10, which is equal to 16 in decimal. Notice
the pattern, once the Hex number reaches the end
of the cycle 1F, it matches the Decimal number
31 or actually 32 numbers since we started at
zero, then starts over at 10, 20, 30, 40, etc.
So putting it all together:
23D (hex) = 2*162 + 3*161 + 13*160 = 573 (dec)
In 23D, the 2 from 23D is multiplied by 16 to
the second power, base16 or (512), and we count
the powers as from 0 to X, and the second value
3 is multiplied by 16 to the first power or 16
(48) as it is the second value, and D which is a
Decimal 13 is added to 16 to the zero power or
zero as D is the first value (13):
4
2 * 16(2) = 512
3 * 16(1) =
48
13 + 0
13
=
573
The Rosetta Stone Binary to Hex
Likewise, Binary relates to Hex in the following
pattern:
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
->
->
->
->
->
->
->
->
->
->
->
->
->
->
->
->
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
5
Type in an F using the Hex Tab, Then click on
the Bin Tab.
6
And the binary number of 1111 appears!
The Rosetta Stone ASCII to Hex to Symbol
The following chart will help tie computer
language into understandable English:
7
ASCII Hex Symbol
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
NUL
SOH
STX
ETX
EOT
ENQ
ACK
BEL
BS
TAB
LF
VT
FF
CR
SO
SI
ASCII Hex Symbol
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
40
41
42
43
44
45
46
47
48
49
4A
4B
4C
4D
4E
4F
@
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
ASCII Hex Symbol
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
10
11
12
13
14
15
16
17
18
19
1A
1B
1C
1D
1E
1F
ASCII Hex Symbol
DLE
DC1
DC2
DC3
DC4
NAK
SYN
ETB
CAN
EM
SUB
ESC
FS
GS
RS
US
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
ASCII Hex Symbol
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
50
51
52
53
54
55
56
57
58
59
5A
5B
5C
5D
5E
5F
20 (space)
21
!
22
"
23
#
24
$
25
%
26
&
27
'
28
(
29
)
2A
*
2B
+
2C
,
2D
2E
.
2F
/
ASCII Hex Symbol
P
Q
R
S
T
U
V
W
X
Y
Z
[
\
]
^
_
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
60
61
62
63
64
65
66
67
68
69
6A
6B
6C
6D
6E
6F
`
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
ASCII Hex Symbol
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
30
31
32
33
34
35
36
37
38
39
3A
3B
3C
3D
3E
3F
ASCII Hex Symbol
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
70
71
72
73
74
75
76
77
78
79
7A
7B
7C
7D
7E
7F
So the word Nike would equal 4E696B65 in Hex!
8
0
1
2
3
4
5
6
7
8
9
:
;
<
=
>
?
p
q
r
s
t
u
v
w
x
y
z
{
|
}
~
•
Conclusion
By knowing how Hex, Dec, Bin, ASCII, and Symbols
are related, you will be able to decipher Core
Dumps and other Computer related issues! Also,
check the Sites to automatically convert Text to
Hex and vise-versa!
http://www.swingnote.com/tools/texttohex.php
http://www.string-functions.com/hex-string.aspx
9
Download