intro to hexadecimal

something i wrote up in the early 2000’s. includes some binary and octal info as well…

hexadecimal
hexadecimal is most commonly used to represent large amounts of binary (machine code 01010011..etc) in a small amount of characters. it’s also used for numbering memory and physical addresses (C800:5). hex, which it is more often called, is a base-16 number system that uses the characters 0-F (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F) to represent the numbers 0-15. 0=0, F=15

converting between binary and hex is very simple, like so:

1101 0011 1001 0110 (1101001110010110, binary word shown in nibbles to go easy on the eyes)
13      3        9        6
^above you see what these nibbles equal. now here is the hex representation D396.

that shouldn’t be too hard to follow the ‘396’ is very straight forward. ‘D’ may seem odd though. all D represents is the number 13..no mystery to it. A=10, B=11, C=12, D=13, E=14, F=15. therefore D396. now you could convert in other ways, but by far, breaking the binary word into nibbles first is the easiest approach. obviously it is much more convenient to write long binary words in hex.

here is the opposite, converting hex to binary:

AB0C
A=10 B=11 0=0 C=12
1010 1011 0000 1100

now the more difficult conversion between hex and decimal:

the base-10 (decimal) numbers 0-15 are already taken care of  ‘0-F’. what happens when 16+ must be represented?..16 in hex becomes ’10’ and 17 ’11’ and 18 ’12’

a closer look: ’10’ to the farthest left is the “10’s column” in decimal. so here it is (1 *16) + (0 *1) = 16

powers of 16:
0 – 1
1 – 16
2 – 256
3 – 4096
4 – 65,536
5 – 1,048,576
6 – 16,777,216

binary
0,1
powers of 2:
0 – 1
1 – 2
2 – 4
3 – 8
4 – 16
5 – 32
6 – 64
7 – 128
8 – 256
9 – 512
10 – 1024

octal
0-7
each octal digit represents 3 bits
powers of 8:
0 – 1
1 – 8
2 – 64
3 – 512
4 – 4096

links:
decimal/binary converter (including fractions) – http://www.exploringbinary.com/binary-converter/
binary addition/subtraction calculator – http://www.csgnetwork.com/binaddsubcalc.html
binary multiplication/division calculator – http://www.csgnetwork.com/binmultdivcalc.html
base2 to base20 calculator – http://www.cleavebooks.co.uk/scol/calnumba.htm
base conversions 2-36 to decimal (including fractions) – http://www.easysurf.cc/cnver17.htm#batob10
2’s complement calculator – http://easycalculation.com/twos-complement.php
BCD converter – http://ncalculators.com/digital-computation/bcd-decimal-converter.htm

This entry was written by resinblade , posted on Sunday January 29 2012at 07:01 pm , filed under IT . Bookmark the permalink . Post a comment below or leave a trackback: Trackback URL.

Leave a Reply

You must be logged in to post a comment.