Decimal to octal converter
Type a decimal number to get it in octal, with the division steps.
Prefixes 0b, 0o, 0x and spaces or underscores between digits are fine. A point starts the fraction.
How to convert decimal to octal
Divide by 8 and write down the remainder, which is 0 to 7. Divide the quotient by 8 again until it reaches 0, then read the remainders from the bottom up.
| Divide | Quotient | Remainder |
|---|---|---|
| 493 ÷ 8 | 61 | 5 |
| 61 ÷ 8 | 7 | 5 |
| 7 ÷ 8 | 0 | 7 |
Reading the remainders from the bottom up gives 755, so 49310 = 7558.
Octal digits in binary
| Octal | Binary | Decimal |
|---|---|---|
| 0 | 000 | 0 |
| 1 | 001 | 1 |
| 2 | 010 | 2 |
| 3 | 011 | 3 |
| 4 | 100 | 4 |
| 5 | 101 | 5 |
| 6 | 110 | 6 |
| 7 | 111 | 7 |
Common mistakes
Reading remainders top down
200 gives remainders 0, 1, 3; read top down that’s 013, but 200 is 310
Instead: Read the remainders from the last division back to the first
Stopping too early
Leaving out the final remainder when the quotient reaches 0
Instead: Keep dividing until the quotient is 0; the last remainder is the leftmost digit
Writing a remainder of 8
A remainder is always 0 to 7 when dividing by 8
Instead: If you get 8 or more, the division step is wrong
Writing permissions in octal
The usual reason to convert into octal is a Unix file mode. In the POSIX chmod command each permission is a bit with an octal value: read 4, write 2 and execute 1, in one digit each for the owner, the group and others. Add the bits you want in each digit.
| Wanted | Owner | Group | Others | Octal mode |
|---|---|---|---|---|
| Owner all, others read and execute | 4 + 2 + 1 | 4 + 1 | 4 + 1 | 755 |
| Owner read and write, others read | 4 + 2 | 4 | 4 | 644 |
| Owner read and write only | 4 + 2 | 0 | 0 | 600 |
Sources and method
Conversions use exact whole-number arithmetic (JavaScript BigInt), so long numbers keep every digit. Fractions are kept as exact ratios; when the digits repeat, the repeating block is found and marked instead of rounded.
Questions
How do I check the answer?
Convert it back: multiply each octal digit by its power of 8 and add. The octal to decimal converter shows that working.
Is there a quicker way through binary?
Yes. Write the number in binary, group the bits in threes from the right, and swap each group for one octal digit.