Octal to decimal converter
Type an octal number to get its decimal value, with the working.
Prefixes 0b, 0o, 0x and spaces or underscores between digits are fine. A point starts the fraction.
How to convert octal to decimal
Octal uses the digits 0 to 7, and each place is worth 8 times the place to its right: 1, 8, 64, 512, 4096 and so on. Multiply each digit by its place value and add. To go the other way, use decimal to octal.
| Digit | Place value | Digit × place value |
|---|---|---|
| 7 | 82 = 64 | 448 |
| 5 | 81 = 8 | 40 |
| 5 | 80 = 1 | 5 |
448 + 40 + 5 = 493, so 7558 = 49310.
Where octal still shows up
Unix file permissions are written in octal. Each digit is three bits, one for read (4), write (2) and execute (1), for the owner, the group and everyone else. So 755 means rwx for the owner (4 + 2 + 1) and r-x for the others (4 + 1).
| Octal | Bits | Permission |
|---|---|---|
| 7 | 111 | read, write, execute |
| 6 | 110 | read, write |
| 5 | 101 | read, execute |
| 4 | 100 | read only |
| 0 | 000 | none |
Common mistakes
Multiplying by 10s
Reading 17 as 1 × 10 + 7 = 17 instead of 1 × 8 + 7 = 15
Instead: Each place is worth 8 times the one to its right: 1, 8, 64, 512
Starting the powers from the left
Giving the leftmost digit place value 1
Instead: Count places from the right; the rightmost digit is worth 1
Accepting an 8 or 9
A number like 189 isn’t octal, so any answer is wrong
Instead: Check the digits first; the converter flags 8 and 9
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
Why is there no 8 or 9 in octal?
Base 8 only needs eight digits, 0 to 7. After 7 comes 10, which means one eight and no ones.
What does a leading 0 or 0o mean?
In C and older JavaScript a leading 0 marks an octal number; Python and modern JavaScript use 0o. The converter accepts 0o and ignores it.