# 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 64_{10}) + (4 x 8_{10}) + (5 x 1_{10}) + (3 x 0.125_{10}) + (7 x 0.015625_{10}) = 165.484375_{10}

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.A9_{16} 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 256_{10}) + (0 x 16_{10}) + (15 x 1_{10}) + (10 x 0.0625_{10}) + (9 x 0.00390625_{10}) = 783.66015625_{10}

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.