Computing Library › Number Systems & Information
Number Systems & Information

Octal Number System

Octal is base 8, a compact shorthand for binary where each digit stands for exactly three bits.

Base eight

Octal uses the digits 0 through 7. Each place has weight a power of eight, so 0o17 means 1×8 + 7 = 15 in decimal. Because 8 = 2³, one octal digit maps cleanly onto a group of three bits.

Binary grouping

Kronos motion — three machines

To convert binary to octal, group the bits in threes from the right and read each group as a digit. The binary 110101 splits into 110 and 101, giving octal 65.

Where it appears

Octal predates hexadecimal in computing and survives in a few places, most visibly in Unix file permission codes such as 0o755, where each octal digit encodes the read, write, and execute bits for one class of user.

Conversion back to decimal

Apply positional notation directly: multiply each digit by its power of eight and sum. Converting to decimal or hexadecimal is easiest by passing through binary.

Limitations

Octal has faded because a byte is eight bits, which does not divide evenly into groups of three. Hexadecimal, with each digit covering four bits, aligns to byte boundaries and is now preferred.

python
print(0o17)        # 15
print(oct(15))     # '0o17'
print(0o755)       # 493