Convert decimal to octal
Octal uses the eight digits 0 to 7.
To convert a decimal value to octal, divide by 8 and keep each remainder.
Read the remainders from the last division up. The value 300 gives 454.
Try decimal to octal conversion in the bit editor
The value 300, which is 0o454. Edit the expression or select a bit to flip it.
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
0o454
octal · 16 bits
- value
- 300
Decimal to octal conversion step by step
Divide the value by 8 and keep every remainder: The steps follow the value above.
- 300 / 8 = 37 remainder 4
- 37 / 8 = 4 remainder 5
- 4 / 8 = 0 remainder 4
- Read the remainders from the last line up: 454
The weight of each octal position
| Position | Weight | Decimal value |
|---|---|---|
| 0 | 8^0 | 1 |
| 1 | 8^1 | 8 |
| 2 | 8^2 | 64 |
| 3 | 8^3 | 512 |
| 4 | 8^4 | 4096 |
| 5 | 8^5 | 32768 |
Where decimal to octal conversion is used
A Unix file permission is three octal digits, one for each group of three bits.
An older assembler and an older format both write constants in octal.
Octal maps to bits in groups of three, so it suits a field of three bits.
Decimal to octal conversion: points to note
- A zero at the front marks an octal literal in C. The literal 010 is 8, not 10.
- Python writes an octal literal as 0o10. The prefix 0o avoids the trap above.
- Octal has no digit 8 and no digit 9. A digit above 7 is not a valid octal digit.
- Hex fits a byte in two digits and octal does not, so hex suits an 8-bit register better.
The full bit editor
The full editor holds many values, evaluates expressions across them, and reads live values from a serial port.
Open this value in the full editorQuestions about decimal to octal conversion
- What is 300 in octal?
- The value 300 is 454 in octal, because 300 is 4 x 64 plus 5 x 8 plus 4.
- Why does a file permission use octal?
- Each permission group holds three bits for read, write and execute, and one octal digit holds exactly three bits.
- How do I convert octal to binary?
- Replace each octal digit with its three bits, then join the groups.