What is Decimal to Octal Converter?
This decimal to octal converter and calculator turns base-10 numbers into base 8, where digits run from 0 to 7. 8 is 10 in octal, 64 is 100, and 493 is 755, the familiar Unix permission code.
Octal is mostly encountered today in Unix and Linux file permissions, in older documentation and systems, and in number-base exercises. Enter one number or several separated by spaces or commas, and each is converted instantly, with your choice of output separator.
How to use Decimal to Octal Converter
- Enter decimal numbers separated by spaces or commas, for example 8 64
- Read the octal results.
- Choose the output separator if you converted several values.
- Copy the result, or click Swap to convert octal to decimal.
Key features
- Convert many values at once, separated by spaces or commas
- Exact results for numbers of any size, including 64-bit values
- Output separated by spaces, commas, new lines or nothing
- Uppercase or lowercase hex, optional 0x prefix, and binary padded to whole 8-bit bytes
- Swap button to reverse the conversion direction
- Summary of a single value in binary, octal, decimal, hex and ASCII
- Clear errors for invalid digits; runs entirely in your browser
Common use cases
- Working out octal Unix file permissions from decimal values
- Learning number base conversions
- Reading values in legacy systems that use octal
- Preparing octal literals for C, Python and JavaScript code
- Checking exam and homework answers
Technical details & standards
To convert by hand, divide the number by 8 repeatedly, note the remainders and read them from last to first. For 493: 493 ÷ 8 = 61 remainder 5; 61 ÷ 8 = 7 remainder 5; 7 ÷ 8 = 0 remainder 7, so the answer is 755.
Each value is converted as a whole number, exactly at any size thanks to arbitrary-precision integers. Negative numbers keep their minus sign. Octal is convenient because each octal digit stands for exactly three bits, the reason it suits permission bits (read, write and execute).
How to convert decimal to octal by hand
Divide by 8 until the quotient is 0, then read the remainders backwards. Here is 2879, which needs four octal digits:
- 2879 ÷ 8 = 359, remainder 7.
- 359 ÷ 8 = 44, remainder 7.
- 44 ÷ 8 = 5, remainder 4.
- 5 ÷ 8 = 0, remainder 5. The quotient is 0, so stop and read the remainders from the bottom up: 5, 4, 7, 7.
Result: 2879 in decimal is 5477 in octal. Check it with place values: 5 × 512 + 4 × 64 + 7 × 8 + 7 = 2879.
Decimal to octal in JavaScript, Python and C
Octal output is built into each language; C's %o format is the one chmod values usually come from.
JavaScript
(2879).toString(8); // "5477"
(172).toString(8); // "254"Python
oct(2879) # '0o5477'
format(172, "o") # '254'C
#include <stdio.h>
int main(void) {
printf("%o\n", 2879); /* 5477 */
printf("%#o\n", 493); /* 0755 */
return 0;
}Decimal to octal conversion table
Common decimal numbers with their octal form and the repeated division that produces it. Each step shows the quotient and the remainder (r) after dividing by 8; read the remainders from the last step back to the first to get the octal digits.
| Decimal | Octal | Dividing by 8 | Notes |
|---|---|---|---|
| 8 | 10 | 1 r0, 0 r1 | The base itself, so it is written 10 |
| 16 | 20 | 2 r0, 0 r2 | Two eights and no units |
| 64 | 100 | 8 r0, 1 r0, 0 r1 | 8 × 8, where a third octal digit appears |
| 100 | 144 | 12 r4, 1 r4, 0 r1 | Round in decimal, but not in octal |
| 172 | 254 | 21 r4, 2 r5, 0 r2 | Remainders 4, 5 and 2, read from the last one up as 254 |
| 247 | 367 | 30 r7, 3 r6, 0 r3 | A typical exam question, worked step by step in the FAQ below |
| 255 | 377 | 31 r7, 3 r7, 0 r3 | The largest value of a single byte |
| 420 | 644 | 52 r4, 6 r4, 0 r6 | The number behind chmod 644 |
| 493 | 755 | 61 r5, 7 r5, 0 r7 | The number behind chmod 755 |
| 511 | 777 | 63 r7, 7 r7, 0 r7 | The number behind chmod 777 |
| 512 | 1000 | 64 r0, 8 r0, 1 r0, 0 r1 | 8 × 8 × 8, written 1000 |
| 1000 | 1750 | 125 r0, 15 r5, 1 r7, 0 r1 | Four divisions are needed |
| 2879 | 5477 | 359 r7, 44 r7, 5 r4, 0 r5 | Worked step by step in the section above |
Frequently asked questions
How do I convert decimal to octal?
Divide by 8 repeatedly, write down each remainder, and read the remainders in reverse. 100 ÷ 8 = 12 remainder 4, 12 ÷ 8 = 1 remainder 4, 1 ÷ 8 = 0 remainder 1, so 100 is 144 in octal.
What is 8 in octal?
10. Octal has no digit 8, so eight is written as 1 group of eight and 0 units, just as ten is written 10 in decimal.
What is 493 in octal?
755, the permission code for rwxr-xr-x. Likewise 420 in decimal is 644 in octal (rw-r--r--).
How do I convert decimal to octal in code?
JavaScript: (493).toString(8) returns "755". Python: oct(493) returns '0o755'.
What is the formula for decimal to octal conversion?
Repeated division by 8: divide the number by 8, write down the remainder (0–7), divide the quotient again, and stop at 0. The remainders read from last to first are the octal digits. For 64: 8 r0, 1 r0, 0 r1, giving 100.
What is 100 in octal?
100 is 144 in octal: 100 ÷ 8 = 12 remainder 4, 12 ÷ 8 = 1 remainder 4 and 1 ÷ 8 = 0 remainder 1, so reading the remainders from last to first gives 144.
What is 247 in octal?
367. Step 1: 247 ÷ 8 = 30 remainder 7. Step 2: 30 ÷ 8 = 3 remainder 6. Step 3: 3 ÷ 8 = 0 remainder 3. Reading the remainders upward gives 367; check it with 3×64 + 6×8 + 7 = 247.
How do I convert a decimal fraction to octal?
Convert the whole part by dividing by 8, then multiply the fractional part by 8 repeatedly, taking the whole-number part each time as the next digit. For 0.375: 0.375 × 8 = 3.0, so 0.375 is 0.3 in octal, and 12.375 is 14.3. This converter handles whole numbers, so work out fractions this way.