digiwleeaLearn
Open the lab →

Octal

Three bits to a digit

3 min read

Octal is base 8: each octal digit runs 0 to 7 and stands for exactly three binary bits, making it a compact shorthand for binary that predates hexadecimal and still appears in Unix file permissions and some legacy encodings.

Hexadecimal shrinks long binary strings by packing four bits into one digit. Octal does the same trick with three bits per digit, so it uses only the digits 0 through 7. It is the older shorthand (it fit the 6-, 12-, and 36-bit machines of the 1960s, whose word sizes divided evenly by 3), and hex has mostly replaced it, but octal still turns up, most famously in Unix file permissions like chmod 755.

Converting: group bits by three

Because one octal digit is exactly three bits, converting is pure grouping, no arithmetic. Starting from the right, split the binary into groups of three bits and write the value of each group:
110 101
= 6 5
= 65 (octal) (110 = 6, 101 = 5)
Going the other way, expand each octal digit into its three bits: 72 in octal is 111 010 in binary. If the leftmost group is short, pad it with leading zeros. Compare this to hex, which groups by four: the same byte 0b11101010 is EA in hex (two groups of four) but 352 in octal (11 101 010, padded to 011 101 010).
octal digitthree bitsdecimal
00000
30113
51015
71117
Each octal digit is a fixed 3-bit pattern. There is no digit above 7, because three bits top out at 111 = 7.
Common mistakes. Octal has no 8 or 9 digit, so 18 is not a valid octal number. Group bits from the right, not the left, or a trailing bit lands in the wrong digit. And watch the leading-zero convention: in many programming languages a number written with a leading 0 (like 0755) is read as octal, a classic source of bugs when someone means the decimal 755.
Try it
Convert the binary 110101 to octal, then to decimal, and check they agree.

Frequently asked

What is octal?

Octal is base 8: it uses the digits 0 to 7, and each digit stands for exactly three binary bits. It is a compact shorthand for binary, older than hexadecimal, still seen in Unix file permissions and some legacy machine encodings.

How do you convert binary to octal?

Split the binary into groups of three bits starting from the right (pad the leftmost group with zeros if needed), then write the value of each group. For example 110101 becomes 110 101 which is 65 in octal.

What is the difference between octal and hexadecimal?

Both are shorthands for binary, but octal packs three bits per digit (digits 0 to 7) while hexadecimal packs four (digits 0 to F). Hex lines up with 8-, 16-, and 32-bit words, which is why it replaced octal on modern machines.
Octal, hex, and decimal are all just positional bases over the same bits. Next, the units of storage lesson counts how many of those bits make a byte and a kilobyte.

Every lesson here builds toward one thing: a working CPU, from the transistor up.

Open the free lab →
Found this useful? Share itShare on X