How do I convert this hexadecimal address to a decimal address?
0*FFFF0000
Use the Windows Calculator to convert from Hex to Decimal:
Choose "Programmer" option from the "View" menu:
Make sure that you enter the number while the calculator is in "Hex" mode. After entering the number switch to "Decimal" mode. And you have the answer...
Each placeholder is worth whatever the base is set to. In decimal it is 10. So the number 123 for instance:
The same idea applies to base 16 (e.g., hexadecimal -- hex meaning 6 and decimal meaning 10 -- 16). Each placeholder goes up to 16. Since we're used to only 10 digits, we substitute letters for 11 through 15. In hexadecimal, one placeholder can have values 0 through 15.
Decimal: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Hexadecimal: 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14
0*
indicates that it's base 16 (although this is the first time I've seen it). Another popular notation ix 0x
.
For your example, there are 8 places. FFFF0000
means:
(15 * 16^7) + (15 * 16^6) + (15 * 16^5) + (15 * 16^4) + (0 * 16^3) + (0 * 16^2) + (0 * 16^1) + (0 * 16^0) = 4,294,901,760 = 0*FFFF0000
Sounds complicated right? It's not, really. The same thing is done with decimal:
(4 * 10^9) + (2 * 10^8) + (9 * 10^7) + (4 * 10^6) + (9 * 10^5) + (0 * 10^4) + (1 * 10^3) + (7 * 10^2) + (6 * 10^1) + (0 * 10^0) = 4,294,901,760 = 0*FFFF0000
Wikipedia's page on Hexadecimal goes into more detail.
Your question is tagged with IP, so that uses dotted decimal notation -- a lot easier than that. Usually it's expressed in 255.255.255.255. The great thing about Hexadecimal is that it can represent this very easily as FF is 255. Your address in question translates to 255.255.0.0 and then in dotted hexadecimal notation (is there such a thing?) it's FF.FF.00.00.
0*FFFF0000
How about doing it manually? ;)
0x16^0 + 0x16^1 + 0x16^2 + 0x16^3 + 15x16^4 + 15x16^5 + 15x16^6 + 15x16^7 =
0x1 + 0x16 + 0x256 + 0x4096 + 15x65536 + 15x1048576 + 15x16777216 + 15x268435456 =
0 + 0 + 0 + 0 + 983040 + 15728640 + 251658240 + 4026531840 =
4294901760
As you have asked how to convert hex to binary and the other way around here's the answer:
Hex to binary and the other way around is pretty simple. Just convert each character of the hex string into 4-bit binary value:
0: 0000
1: 0001
2: 0010
3: 0011
4: 0100
5: 0101
6: 0110
7: 0111
8: 1000
9: 1001
A: 1010
B: 1011
C: 1100
D: 1101
E: 1110
F: 1111
So 0xFFFF0000 is:
F F F F 0 0 0 0
1111 1111 1111 1111 0000 0000 0000 0000
another example of 0x0FA10021:
0 F A 1 0 0 2 1
0000 1111 1010 0001 0000 0000 0010 0001
4294901760 (minus the 0*)
Use TFM's method or use an online calc although real coders do it in there head. Ok that last parts a lie but at least we claim to.
x
, indicating that it's hexadecimal by starting with0x
.