Hexadecimal Arithmetic In Your Head Still Useful

Field Computer Programming
Went Obsolete In the late 1980s. Still used by Embedded Programmers.
Made Obsolete By hexadecimal calculators and calculating programs on computers
Knowledge Assumed what hexadecimal numbers are
When useful when looking at hex dumps of communication protocol traces or programs

Still used by embedded programmers during debugging and low level operations. Knowing that 03 20 in a hex dump is 800 in decimal is handy if you're looking at at raw hex (hexadecimal) dump of data.

Hexadecimal, for those who don't already know, is just another way to represent numbers. We typically use the decimal system (where deca is from the Greek word for ten) which has ten digits. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. The hexadecimal (hex from the Greek word for 6) system is similar except that it uses sixteen digits instead of ten. They start out with the same ten as in decimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and then continue using letters A, B, C, D, E and F, which stand for the values 10, 11, 12, 13, 14, and 15. In the same way that 213 is 2*100 + 1*10 + 3 in decimal, or 2*10^2 + 1*10^1 + 3*10^0, in hexadecimal which is often designated by prefixing 0x or appending h in various computer programming languages, 0x213 would mean 2*16^2 + 1*16^1 + 3*16^0 = 2*256 + 16 + 3 = 513. Sometimes the alphabetic digits are specified as uppercase, but many people find lowercase easier to read.

Remembering a lot of hex math is difficult, but just remembering your hex times tables (just a slight variation on the ones you memorized in the second grade) isn't too hard.

0 1 2 3 4 5 6 7 8 9 a b c d e f
0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
1 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
2 00 02 04 06 08 0a 0c 0e 10 12 14 16 18 1a 1c 1e
3 00 03 06 09 0c 0f 12 15 18 1b 1e 21 24 27 2a 2d
4 00 04 08 0c 10 14 18 1c 20 24 28 2c 30 34 38 3c
5 00 05 0a 0f 14 19 1e 23 28 2d 32 37 3c 41 46 4b
6 00 06 0c 12 18 1e 24 2a 30 36 3c 42 48 4e 54 5a
7 00 07 0e 15 1c 23 2a 31 38 3f 46 4d 54 5b 62 69
8 00 08 10 18 20 28 30 38 40 48 50 58 60 68 70 78
9 00 09 12 1b 24 2d 36 3f 48 51 5a 63 6c 75 7e 87
a 00 0a 14 1e 28 32 3c 46 50 5a 64 6e 78 82 8c 96
b 00 0b 16 21 2c 37 42 4d 58 63 6e 79 84 8f 9a a5
c 00 0c 18 24 30 3c 48 54 60 6c 78 84 90 9c a8 b4
d 00 0d 1a 27 34 41 4e 5b 68 75 82 8f 9c a9 b6 c3
e 00 0e 1c 2a 38 46 54 62 70 7e 8c 9a a8 b6 c4 d2
f 00 0f 1e 2d 3c 4b 5a 69 78 87 96 a5 b4 c3 d2 e1

HTML colors can still be specified as hexadecimal numbers. How else would you know that FF8855? is a bright red and E4056B? is a purple?

 
skills/hexadecimalarithmeticinyourheadstilluseful.txt · Last modified: 2009/01/13 11:33 (external edit)
 
Recent changes RSS feed Creative Commons License Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki