Decimal to Octal Converter
Convert a decimal integer into octal using repeated division by 8.
What the converter returns
Enter a decimal integer and the tool returns its base-8 numeral. The default is 64, which becomes 100. That is not a mistake: 64 is exactly 8 squared, so the octal form is a 1 followed by two zeros, just as 100 in decimal is 10 squared.
The output uses digits 0 through 7 only. There is no prefix and no padding, so the length is whatever the value needs, and a leading zero is never printed.
The formula: divide by eight
Each division by 8 leaves a remainder from 0 to 7, and each remainder is one octal digit. The first remainder is the least significant digit, so the digits are read upward after the loop. The procedure is the same one that converts to binary or hex; only the divisor changes.
Because 8 = 23, the process has a shortcut: every three binary digits correspond to one octal digit. Converting through binary is sometimes easier than dividing repeatedly, especially for values you already know in binary form.
Worked example: 64 becomes 100
Divide 64 by 8: quotient 8, remainder 0. Divide 8 by 8: quotient 1, remainder 0. Divide 1 by 8: quotient 0, remainder 1. Read the remainders upward, and the answer is 100.
Why hex replaced octal for bytes
A byte is eight bits, and eight does not divide by three. Octal representation of a byte runs 3 + 3 + 2, so the leading group changes size and the columns stop lining up. Hex splits the same byte into 4 + 4, two equal digits every time. That single mismatch is why memory dumps, color codes and byte arrays are written in hex while permissions stayed octal.
Expand it to check: 1 × 64 + 0 × 8 + 0 × 1 = 64. Three octal digits reach 511, four reach 4,095, and each added digit multiplies the ceiling by eight.
- 8 is 10 in octal
- 64 is 100 in octal
- 511 is 777 in octal
- 512 is 1000 in octal
The binary route
64 in binary is 1000000. Group in threes from the right: 1 000 000. Those groups are 1, 0 and 0, which read as 100 in octal. Because the grouping is lossless, reading a binary pattern as octal is often faster than dividing, and it never produces a different answer.
Place values and useful reference points
| Octal | Expansion | Decimal |
|---|---|---|
| 10 | 8 | 8 |
| 100 | 64 | 64 |
| 777 | 7×64 + 7×8 + 7 | 511 |
| 1000 | 512 | 512 |
| 1777 | 512 + 511 | 1,023 |
The 777 row is worth remembering: three sevens are 511, one less than 512. That is the ceiling of a nine-bit field, which is why octal was a natural fit for machines with nine-bit or eighteen-bit words and for permission fields that are exactly three bits wide.
Octal in Unix file permissions
A permission triple has three bits — read, write and execute — so one octal digit encodes one class of user. The first digit is the owner, the second the group, the third everyone else. Mode 755 means the owner gets 7 (read, write, execute), and the group and others get 5 (read and execute).
| Mode | Digits | Meaning |
|---|---|---|
| 755 | 7 5 5 | owner full, group and others read and execute |
| 644 | 6 4 4 | owner read and write, others read only |
| 700 | 7 0 0 | owner only, no access for anyone else |
| 777 | 7 7 7 | full access for everyone |
Convert 755 to decimal and you get 493, which is why permission numbers in code are almost always written in octal. The three-digit grouping carries the meaning; the decimal value does not. Most languages spell it with a 0o prefix, as in 0o755, precisely to stop a reader from assuming base 10.
Where the conversion bites
- Reading 755 as seven hundred and fifty-five rather than as three permission digits worth 493
- Dropping the prefix so a parser treats the numeral as decimal
- Writing 08 or 09, which are invalid octal digits and will fail or truncate in strict parsers
- Assuming octal is still a common storage format, when hex replaced it for bytes because 8 does not divide 8 evenly
- Forgetting that leading zeros were once significant: 0644 in C is octal, while 644 is decimal
The 08 problem shows up in date strings. A zero-padded month such as 09 is a perfectly good decimal rendering but an illegal octal numeral, so code that parses it with base 8 returns 0 or throws. Specify the base explicitly whenever the input might be padded.
Range and precision
Inputs are rounded to whole numbers and capped at 1015. A million converts to 3641100, seven digits, because 87 is 2,097,152 and 86 is only 262,144. Within the allowed range every conversion is exact, since the value stays inside the band where integers are represented without loss.
One note on output conventions: octal values are sometimes written with a leading zero, as in 0755, and sometimes with 0o755. This tool prints neither, so add whichever your target language expects. A bare 755 is unambiguous as a numeral but will be read as decimal by a parser that has no context.
Frequently asked questions
How do I convert 64 to octal?
Divide by 8 three times: 64 gives quotient 8 remainder 0, 8 gives quotient 1 remainder 0, and 1 gives quotient 0 remainder 1. Read upward for 100.
Why is 64 written as 100 in octal?
Because 64 = 82. Position values in octal are 1, 8, 64, so a 1 in the third position means 64 and the two lower positions are zero.
What is 255 in octal?
377. It is 3×64 + 7×8 + 7 = 192 + 56 + 7, and it is the octal form of the largest byte value.
Why do file permissions use octal?
Each permission class has exactly three bits, and one octal digit is exactly three bits. So read, write and execute map to a single digit from 0 to 7, and three classes make a tidy three-digit mode.
What does chmod 755 mean in decimal?
755 octal is 493 decimal. The digits are not a decimal number, they are three permission triples: 7 for the owner, 5 for the group, 5 for others.
Why is there no digit 8 in octal?
Base 8 has eight digits, 0 through 7. The value eight is written as 10, carrying into the next position, exactly as ten is written 10 in decimal.
What is 1,000,000 in octal?
3641100. It has seven digits because 87 = 2,097,152 is the first power of eight larger than one million.
How many bits does one octal digit represent?
Three, since 8 = 23. That is why octal is convenient for nine-bit fields and awkward for bytes, which split into 3 + 3 + 2.
Is 078 a valid octal number?
No. The 8 is not an octal digit, so the numeral is invalid. Strict parsers reject it, and lenient ones may stop at the 7.
Method and sources
- Positional numeral system, base 8.