Search code examples
binaryoctal

Convert a 16 Bit Binary Value to Octal


Hello I would like to know of a quick and easy way to perform a number conversion of this binary value:

1000100000001011 to octal.

In hex I can convert fairly quickly by hand to 0xAA0B. To come up with the decimal value of this binary takes a bit more work but eventually you can arrive at 32,768 + 2,048 + 11 = 34,827.

I know the octal pattern works like 8 = 10, 9 = 11 .... 16 = 20, 17 = 21 ... 24 = 30, etc. However I am having trouble converting to octal without a large amount of effort.

Could anybody clear this up for me and perhaps provide a short-hand method that can help convert binary to octal. Programming examples are nice but I'm really looking for an explanation. Thanks


Solution

  • The quickest method is to break the binary number into 3-bit chunks from the right end, pad with 0's from the left as needed, then convert each chunk to an octal digit.

    For example,

    1000100000001011 -> 001 000 100 000 001 011 [2 0's added to the left]
                     ->   1   0   4   0   1   3
                     -> 104013