Hexadecimal

From Rosetta Code
Revision as of 02:10, 31 January 2009 by rosettacode>Onyxwolf3 (New page: Hexadecimal code is essentially a shorthand version of binary code. While binary code works using base 2 units, hexadecimal uses base 16. Hexadecimal is used as a shorthand of binary becau...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Hexadecimal code is essentially a shorthand version of binary code. While binary code works using base 2 units, hexadecimal uses base 16. Hexadecimal is used as a shorthand of binary because binary code is hard for humans to comprehend.

Instead of using only 0's and 1's, or 0-9, hexadecimal uses 0-9 just like base 10, but also A-F. A=10, B=ll, and so forth. The most convenient method of converting binary to hexadecimal is to first separate the byte (8 digits) into 2 nibbles (4 digits). Then, convert each nibble into base 10, at which point 10-15 are changed into letters. That's it.

Ex.

   10010110
   1001   0110
   2^0+2^3     2^1+2^2
     9            5
         95