Convert Decimal to Octal

Convert decimal to octal using repeated division by 8. Step-by-step worked examples, practical tips, and connections to Unix file permissions are explained.

Decimal (Base 10)Octal (Base 8)Conversion

Detailed Explanation

Converting decimal to octal follows the same repeated-division approach used for other base conversions, but dividing by 8 at each step. Since all remainders will be in the range 0-7, no letter substitution is needed.

Step-by-step example — converting 493 to octal:

  1. Divide 493 by 8: quotient = 61, remainder = 5
  2. Divide 61 by 8: quotient = 7, remainder = 5
  3. Divide 7 by 8: quotient = 0, remainder = 7

Read remainders bottom to top: 755. So 493₁₀ = 755₈.

Interesting connection: The number 493 in decimal is the chmod 755 permission value, which is the most commonly used permission setting in Unix. This illustrates how octal provides a natural grouping for 3-bit permission fields.

The subtraction method:

For numbers you know are near a power of 8, subtraction can be faster:

  • Powers of 8: 1, 8, 64, 512, 4096
  • 493 = 7x64 + 5x8 + 5x1 = 755₈

Common decimal-to-octal conversions for permissions:

Decimal Octal Permission Meaning
511 777 rwx for all
493 755 rwxr-xr-x
420 644 rw-r--r--
448 700 rwx------
292 444 r--r--r--

In programming:

JavaScript provides (493).toString(8) returning "755". Python offers oct(493) which returns "0o755". When writing shell scripts, you often need to convert decimal values to their octal equivalents to pass correct permission masks to system calls. Understanding this conversion ensures you set the right access controls on files and processes.

Use Case

DevOps engineers convert decimal permission values to octal when writing infrastructure-as-code scripts that need to set precise file permissions on deployed servers.

Try It — Number Base Converter

Open full tool