Summary: convert decimal to octal, free and private
A decimal to octal converter rewrites a base-10 number in base 8, which uses only the digits 0 to 7. To convert decimal to octal free and privately, type the number into Decimal Input above, for example 111, and the result, 157, appears under Octal Output as you type. Nothing is uploaded: the conversion runs in your browser, and you can check that in the Network tab of DevTools.
By hand, divide by 8 over and over and read the remainders from bottom to top. Each remainder is the next octal digit, starting from the right. Written as a formula, the octal digits dįµ¢ of a number N satisfy N = Ī£ dįµ¢ Ć 8ā±. For the opposite direction, click Octal ā Decimal or open the octal to decimal converter.
Table of Use: decimal numbers and their octal form
| Decimal input | Octal result | What it shows |
|---|---|---|
| 8 | 10 | The first number that needs two octal digits |
| 255 | 377 | The largest value of one byte |
| 493 | 755 | A Unix file mode reported as a plain decimal number |
| 33188 | 100644 | The st_mode of a regular file with mode 644 in Python or C |
| -64 | -100 | The minus sign is kept |
| 0.5 | 0.4 | 4 Ć 8ā»Ā¹ = 0.5, so this fraction ends |
| 0.1 | 0.06314631463146314631 | Never ends in octal: cut off after 20 octal digits |
| 123.45 | 173.34631463146314631463 | Whole part by division, fraction by multiplication, cut off |
| 12345678901234567890 | 1255245230635307605322 | Exact above 2āµĀ³ |
| 1 000 000 | 3641100 | Spaces in groups of three, or underscores, are accepted |
Octal gains a digit at every power of 8, just as decimal gains one at every power of 10. These are the rollover points:
| Power | Decimal | Octal |
|---|---|---|
| 8ā° | 1 | 1 |
| 8¹ | 8 | 10 |
| 8² | 64 | 100 |
| 8³ | 512 | 1000 |
| 8ā“ | 4,096 | 10000 |
| 8āµ | 32,768 | 100000 |
Features
- Exact results. Whole numbers are converted with arbitrary-precision integers, up to 5,000 digits, so nothing is rounded above 2āµĀ³.
- Fractions. Each fraction is multiplied by 8 repeatedly and stays exact. When it has no finite octal form, the result is cut off after 20 octal digits and a note says so.
- Negative numbers. The sign is kept and the absolute value is converted. This is not two's complement.
- Forgiving input. Leading zeros and plus signs, .5 and 5. are accepted, as are spaces in groups of three and underscores. A comma, a letter or a stray space gets an error message that says what is wrong.
- Step-by-Step Calculation. In Single Value mode, Show Steps lists the division steps for the whole part, up to the first 64, and the multiplication steps for the fraction.
- Batch Conversion. One number per line, with failed lines reported by line number.
- Conversion History, Copy and Download. History holds your last 20 conversions in the open page; Download saves decimal-to-octal.txt, or octal-to-decimal.txt in the other direction. In Single Value mode, Swap converts the result back, which is a quick check; in Batch Conversion it only changes the direction. Reset clears the input.
Octal is one of several bases used in computing. To see the same number as bits, try the binary to text converter, the binary to hex converter or the hex to binary converter. For general arithmetic, the scientific calculator and fraction calculator are handy beside it.
How to Use the Decimal to Octal Converter
- Under Conversion Mode, keep Decimal ā Octal selected.
- Choose Single Value, or Batch Conversion for a list with one number per line.
- Type or paste your number into Decimal Input, for example 255 or 0.1.
- Read the answer under Octal Output. A red message explains anything the tool cannot convert.
- Click Show Steps under Step-by-Step Calculation to see the working, or Show Explanation under Educational Mode for the method.
- Click Copy or Download to keep the result, Swap (in Single Value mode) to convert it back, and Reset to clear the input.
Who Can Use a Decimal to Octal Converter
Students of computer science and digital electronics check division and multiplication exercises against the steps. Linux and macOS users translate decimal mode values returned by scripts, such as os.stat in Python, into the octal form that chmod expects. Programmers writing C, Python or JavaScript literals convert a decimal constant to its octal spelling, and anyone preparing test data can feed a column of values, perhaps from the random number generator, through Batch Conversion. Hobbyists who read older computer manuals will also meet octal, and the ASCII to text converter and text to ASCII converter show where character codes fit in.
FAQs
How do I convert decimal to octal?
Divide the decimal number by 8 repeatedly, write down each remainder, and stop when the quotient is 0. Then read the remainders from bottom to top. For 111: 111 Ć· 8 = 13 remainder 7, 13 Ć· 8 = 1 remainder 5, 1 Ć· 8 = 0 remainder 1, so 111 is 157 in octal. The converter does this as you type and lists the steps if you click Show Steps.
How do I convert a decimal fraction to octal?
Convert the whole part by division, then multiply the fraction by 8 repeatedly. The whole-number part of each product is the next octal digit, and you keep the fractional part. So 0.5 Ć 8 = 4.0 gives 0.4. Many fractions never end: 0.1 becomes 0.0631463146ā¦, so the converter cuts the result off, without rounding, after 20 octal digits and tells you it has.
Can I convert negative decimal numbers to octal?
Yes. The converter works on the absolute value and keeps the minus sign, so -64 in decimal is -100 in octal. It writes a signed number, not a two's-complement bit pattern, so it will not show how a negative value is stored in memory. A leading plus sign is accepted and dropped, and -0 is shown as 0.
How large a decimal number can I convert?
Up to 5,000 digits in total, counting both sides of a decimal point. The converter uses arbitrary-precision integers, so results stay exact beyond 2āµĀ³, which is 9,007,199,254,740,992, the point where ordinary JavaScript numbers start rounding. Longer input gets an error message instead of a wrong answer. Commas are rejected, but spaces in groups of three and underscores are accepted.
Why does octal only use the digits 0 to 7?
Octal is base 8, so it needs eight symbols, just as decimal needs ten and binary needs two. Each octal digit stands for exactly three binary digits, which made it a compact shorthand on older computers and still does for Unix file modes such as 755. Decimal 111 is 1101111 in binary, which splits into 1 101 111, or 157 in octal.
How do I convert decimal to octal in Python, JavaScript or the shell?
In Python, format(493, "o") returns 755 and oct(493) returns 0o755. In JavaScript, (493).toString(8) returns "755". In a Unix shell, printf "%o\n" 493 prints 755. Python's format and oct and the shell's printf handle whole numbers only. JavaScript's toString(8) also converts fractions, for example (0.5).toString(8) gives "0.4", but it works in double precision, so it rounds long fractions and loses precision above 2āµĀ³. For exact long numbers or the working, use this converter.
Can I convert a list of decimal numbers at once?
Yes. Click Batch Conversion and enter one decimal number per line. Each line becomes a result such as 64 (decimal) = 100 (octal). A line that is not a valid number is reported with its line number, for example "Line 3: Error", and the other lines still convert. Swap changes the direction for the whole list, so the same lines are then read as octal numbers; it does not convert the results back.
Is it safe to enter my numbers into this converter?
Yes. The conversion runs in your browser with JavaScript, and nothing you type is uploaded; the Network tab in your browser's DevTools will show no request carrying your numbers. Conversion History keeps your last 20 conversions in the open page only, and it is cleared when you reload or leave it.