It is hexadecimal notation, yes. The 0x prefix is the common hex notation prefix. Though $ has also been used, primarily in old (DOS era) applications which had very little screen space.
Prepare yourself for ...
Parasyte's Number Representation TutorialHex is just another number representation. Whereas decimal is base-10, and binary is base-2; hexadecimal is base-16. Converting between different number bases is just a matter of expressing each number as a polynomial equation, and working out the exponents. Here's an example using 2
22:
1. Polynomial expansion of a base-2 number2
22 = 1*2
22 + 0*2
21 + 0*2
20 + 0*2
19 ... + 0*2
2 + 0*2
1 + 0*2
0The final 2
0 can usually be discarded, since any positive number raised to an exponent of 0 is always equal to 1. And the penultimate exponent can also be discarded, because raising any positive number to an exponent of 1 is always equal to the original base. Simplify:
2
22 = 1*2
22 + 0*2
21 + 0*2
20 + 0*2
19 ... + 0*2
2 + 0*2 + 0
Of course, we can also simplify further by removing all the polynomial segments that are 0:
2
22 = 1*2
22And multiplying by 1 is redundant, so we come full circle:
2
22 = 2
22This example is rather boring, because only one digit is set. Things get a little more crazy when converting to base-10 and base-16. So here we go!
2. Polynomial expansion of a base-10 numberIn base-2, each digit may have 2 possible values: 0 or 1. In base-10, each digit may have 10 possible values: 0 through 9. This property alone explains the number in the "base".
Let's take a base-10 number: 4194304 and expand this number as a polynomial expression:
4194304 = 4*10
6 + 1*10
5 + 9*10
4 + 4*10
3 + 3*10
2 + 0*10
1 + 4*10
0Super easy; each digit in the base-10 number is simply multiplied by the polynomial. Simplify if you like:
4194304 = 4*10
6 + 1*10
5 + 9*10
4 + 4*10
3 + 3*10
2 + 4
3. Convert each sub-expression to base-24 =
223*10
2 = 300 = 256+32+8+4 =
28 + 25 + 23 + 224*10
3 = 4000 = 2048+1024+512+256+128+32 =
211 + 210 + 29 + 28 + 27 + 259*10
4 = 90000 = 65536+16384+4096+2048+1024+512+256+128+16 =
216 + 214 + 212 + 211 + 210 + 29 + 28 + 27 + 241*10
5 = 100000 = 65536+32768+1024+512+128+32 =
216 + 215 + 210 + 29 + 27 + 254*10
6 = 4000000 = 2097152+1048576+524288+262144+65536+2048+256 =
221 + 220 + 219 + 218 + 216 + 211 + 28And add all of the expanded expressions together. This is made easier by grouping common exponents, and recursively solving for those. To add exponents, take each group of two common exponents and reduce by removing one expression, and increasing the exponent by 1. For example, there are two
22:
(22 + 22) = 2
3So here's the full series, grouped, and followed by the solution for the first iteration:
2
21 + 2
20 + 2
19 + 2
18 +
(216 + 216) + 2
16 + 2
15 + 2
14 + 2
12 +
(211 + 211) + 2
11 +
(210 + 210) + 2
10 +
(29 + 29) + 2
9 +
(28 + 28) +
(28 + 28) +
(27 + 27) + 2
7 +
(25 + 25) + 2
5 + 2
4 + 2
3 +
(22 + 22) =
2
21 + 2
20 + 2
19 + 2
18 +
(217) + 2
16 + 2
15 + 2
14 + 2
12 +
(212) + 2
11 +
(211) + 2
10 +
(210) + 2
9 +
(29) +
(29) +
(28) + 2
7 +
(26) + 2
5 + 2
4 + 2
3 +
(23)You'll notice the way I grouped these exponents is in groups of two. That's very important. Regroup, and solve again:
2
21 + 2
20 + 2
19 + 2
18 + 2
17 + 2
16 + 2
15 + 2
14 +
(212 + 212) +
(211 + 211) +
(210 + 210) +
(29 + 29) + 2
9 + 2
8 + 2
7 + 2
6 + 2
5 + 2
4 +
(23 + 23) =
2
21 + 2
20 + 2
19 + 2
18 + 2
17 + 2
16 + 2
15 + 2
14 +
(213) +
(212) +
(211) +
(210) + 2
9 + 2
8 + 2
7 + 2
6 + 2
5 + 2
4 +
(24)And again: (Yay! Recursion!)
2
21 + 2
20 + 2
19 + 2
18 + 2
17 + 2
16 + 2
15 + 2
14 + 2
13 + 2
12 + 2
11 + 2
10 + 2
9 + 2
8 + 2
7 + 2
6 + 2
5 +
(24 + 24) =
2
21 + 2
20 + 2
19 + 2
18 + 2
17 + 2
16 + 2
15 + 2
14 + 2
13 + 2
12 + 2
11 + 2
10 + 2
9 + 2
8 + 2
7 + 2
6 + 2
5 +
(25)... until there are no more common exponents ...
2
21 + 2
20 + 2
19 + 2
18 + 2
17 + 2
16 + 2
15 + 2
14 + 2
13 + 2
12 + 2
11 + 2
10 + 2
9 + 2
8 + 2
7 + 2
6 +
(25 + 25) =
2
21 + 2
20 + 2
19 + 2
18 + 2
17 + 2
16 + 2
15 + 2
14 + 2
13 + 2
12 + 2
11 + 2
10 + 2
9 + 2
8 + 2
7 + 2
6 +
(26)The pattern at this point is pretty obvious. If we continue this iteration, we will eventually simplify to
222.
This is just a long-hand explanation for how addition with carry works in binary.
4. What are those magic numbers?There are some magic numbers in the equations above. Take for instance this line:
Quote:
3*102 = 300 = 256+32+8+4 = 28 + 25 + 23 + 22
The numbers 256, 32, 8, and 4 are "magic" numbers, because I didn't really explain how I got them. Obviously, they are the result of solving the exponents on the right side, but there's also no explanation for how I came up with these numbers, either. The answer is kind of depressing; it's just a matter of estimation. You need to answer the question, "what's the biggest power-of-two that fits into 300?" It turns out to be 256, because the next power-of-two is 512, which is greater than 300. Thus, 2
8 fits into 300, but 2
9 does not. Subtract the 256 from 300, and find the biggest power-of-two that fits into that result:
300 - 256 =
442
2 = 4
2
3 = 8
2
4 = 16
25 = 322
6 = 64
Therefore 32 fits into 44, and 2
5 is the next polynomial segment. Repeat until the number is solved. The same estimation steps can be used to convert the other way, as well. Which is what we'll see in the following section.
5. TL;DR: Onward to base-16The biggest power-of-sixteen that fits into 2
22 is 16
5 = 2
20, because
20 is evenly divisible by
4. Why 4? It takes 4 bits to represent one hex digit. This is defined by 16 = 2
4In fact, 16
5 fits into 2
22 exactly 4 times. So:
2
22 = 4*16
5Which can also be written in hex notation as a 4 followed by 5 zeros: 0x400000.
Fin.