# Octal

Octal, also known as "base-8," is a number system that uses eight digits (0 - 7) to represent any integer. Octal values are sometimes used to represent data in computer science since bytes contain eight bits. For example, the octal value "10" can represent 8 bits or 1 byte. "20" represents 2 bytes, 30 represents 3, etc. Octal values are also easily translatable from binary, which uses two digits, and hexidecimal, which uses 16 digits.

To convert an octal value to a standard decimal or "denary" value, multiply each digit by 8^{n}, where *n* is the place of the digit, starting with 0, from right to left. Then add the results together. So **123** in octal can be converted to a decimal value as follows:

**8 ^{0}** x 3 +

**8**x 2 +

^{1}**8**x 1 =

^{2}**3**+

**16**+

**64**=

**83**

The table below shows several equal values in octal, decimal, hexadecimal, and binary:

Octal | Decimal | Hexadecimal | Binary |
---|---|---|---|

1 | 1 | 1 | 1 |

10 | 8 | 8 | 1000 |

50 | 40 | 28 | 101000 |

100 | 64 | 40 | 1000000 |

1234 | 668 | 29C | 1010011100 |

### Binary to Octal Conversion

To convert a binary value to an octal value, separate the digits into groups of three, starting from right to left. Then mulitply each 1 or 0 by 2^{n}, where *n* is the place of each digit, from right to left, starting with 0. For example, to convert the binary value 1010011100 from the table above, first separate the digits as: 1 010 011 100. Then multiply the values as follows:

- 0x1 + 0x2 + 1x4 = 4
- 1x1 + 1x2 + 0x4 = 3
- 0x0 + 1x2 + 0x4 = 2
- 1x1 + 0x2 + 0x4 = 1

The resulting value is: **oct 1234**. Octal values may also be displayed with a subscript "8," such as 1234_{8}. The bottom row of the table above can be written in subscript notation as:

1010011100_{2} = 1234_{8} = 668_{10} = 29C_{16}

Updated: October 3, 2020