Numbers · base 8Octal numbers

Convert a number to octal and back. Type a value in any base — you get the others, a digit-by-digit breakdown and, when the number looks like file permissions, a ready chmod reading.

Everything is computed in your browser — nothing is sent to a server
01Convert02Digit lanes03chmod04Table05About base 806Questions
01

Convert

type a number in any base
Input · octal
Common permissions
Notation
Result
Octal
644
Decimal420
Hexadecimal1A4
Binary110 100 100
Bits in the number9
As file permissions
rw-r--r--
Owner — rw-, group — r--, others — r--.
Break it down bit by bit
02

Digit lanes

step the digits with the arrows — the number changes as you go
66 × 64owner
44 × 8group
48⁰ = 14 × 1others
420
in decimal

Every digit is a value multiplied by a power of eight. Under each digit is its group of three bits: eight is two to the third power, so one octal digit covers exactly three bits. Hence the permissions — read, write and execute are those very three bits.

03

File permissions (chmod)

tick the boxes — the octal code is recomputed
WhoWhat is allowedDigit
Ownerthe file's creator6
Groupthe file's group4
Othersevery other user4
Symbolic notationrw-r--r--Commandchmod 644
Sensible permissions

Only the owner can write — the usual, safe scheme for project files and directories.

Ready-made sets
04

Conversion table

click a row to load the value
DecimalOCTHEXBinaryWhat is notable
777111largest single digit
81081000start of the second digit
64100401000000start of the third digit
100144641100100round in decimal
1282008010000000top bit of a byte
255377FF11111111largest single byte
4206441A4110100100mode 644
4937551ED111101101mode 755
5117771FF111111111mode 777
51210002001000000000start of the fourth digit
1024200040010000000000kilobyte
40957777FFF111111111111four digits at their limit
05

About octal

Octal uses the digits from zero to seven. One digit is exactly three bits, and that is why it outlived the era it was made for: Unix permissions come in triples of read, write and execute, and a triple of bits is one octal digit. Elsewhere hexadecimal replaced it, because hex maps onto a byte exactly.

One digit is three bits

Triad
7 = 111
Eight is two to the third power, so an octal digit covers exactly three bits. Conversion to binary goes digit by digit, with no division.

File permissions

Unix
r=4 · w=2 · x=1
Read, write and execute are three bits, that is one digit. Three digits describe the owner, the group and everyone else: 644, 755, 600.

The leading zero

Syntax
0644 = 420
In C-family languages a leading zero means octal notation. It is a classic source of bugs, so newer languages use the explicit 0o prefix.

Special bits

Fourth digit
4755 · 2755 · 1777
The fourth digit from the right sets setuid, setgid and sticky. For example, 1777 is a shared directory where only the owner of a file may delete it.

Why hex replaced it

History
8 vs 16
A byte is eight bits and does not divide into threes evenly. A hex digit takes four bits, so a byte is exactly two digits. Octal stayed where data is grouped in three-bit chunks.

String escapes

In practice
\101 = A
In C, Python and shell strings a backslash with an octal code denotes a character. You meet it in old scripts and in the output of some utilities.
06

Frequently asked questions

255 in decimal is 377 in octal. Three octal digits cover nine bits, so a byte fits into them with room to spare.

Works with non-negative integers of any length. Permissions are read for three and four digits; what the special bits actually do depends on the system.

«» added to favorites