Octal and hexadecimal to decimal conversion


Although the prime intent of octal and hexadecimal numeration systems is for the "shorthand" representation of binary numbers in digital electronics, we sometimes have the need to convert from either of those systems to decimal form. Of course, we could simply convert the hexadecimal or octal format to binary, then convert from binary to decimal, since we already know how to do both, but we can also convert directly.

Because octal is a base-eight numeration system, each place-weight value differs from either adjacent place by a factor of eight. For example, the octal number 245.37 can be broken down into place values as such:



octal
digits =       2  4  5  .  3  7            
.              -  -  -  -  -  -
weight =       6  8  1     1  1
(in decimal    4           /  /
notation)                  8  6
.                             4


The decimal value of each octal place-weight times its respective cipher multiplier can be determined as follows:



(2 x 6410)  +  (4 x 810)  +  (5 x 110)  +  (3 x 0.12510)  +
(7 x 0.01562510)  =  165.48437510


The technique for converting hexadecimal notation to decimal is the same, except that each successive place-weight changes by a factor of sixteen. Simply denote each digit's weight, multiply each hexadecimal digit value by its respective weight (in decimal form), then add up all the decimal values to get a total. For example, the hexadecimal number 30F.A916 can be converted like this:



hexadecimal
digits =       3  0  F  .  A  9            
.              -  -  -  -  -  -
weight =       2  1  1     1  1
(in decimal    5  6        /  /
notation)      6           1  2
.                          6  5
.                             6


(3 x 25610)  +  (0 x 1610)  +  (15 x 110)  +  (10 x 0.062510)  +  
(9 x 0.0039062510)  = 783.6601562510


These basic techniques may be used to convert a numerical notation of any base into decimal form, if you know the value of that numeration system's base.