Decimal to Octal Converter
Convert decimal numbers to octal instantly, including integers of any size.
Input
Output
Readme
What is a number base?
A number base, or radix, is the number of digits a numeral system uses. Decimal, the everyday system, has ten digits, 0 to 9, and each position is worth ten times the one to its right. Computers work in binary, which has only 0 and 1, so each position is worth twice the one to its right. Octal, with the digits 0 to 7, and hexadecimal, with 0 to 9 and A to F for 10 to 15, are short ways to write binary: an octal digit stands for exactly 3 bits and a hexadecimal digit for exactly 4, so a byte is always two hexadecimal digits.
Here is the same number in each base:
| Decimal | Binary | Octal | Hexadecimal |
|---|---|---|---|
| 10 | 1010 | 12 | A |
| 42 | 101010 | 52 | 2A |
| 255 | 11111111 | 377 | FF |
| 1000 | 1111101000 | 1750 | 3E8 |
| 65535 | 1111111111111111 | 177777 | FFFF |
| -42 | -101010 | -52 | -2A |
Where each base is used
- Binary: bits, flags, bit masks, and subnet masks, such as 255.255.255.0, which is 24 ones followed by 8 zeros.
- Octal: Unix file permissions, such as
chmod 755, where each digit is three permission bits. - Decimal: everyday numbers.
- Hexadecimal: colors such as
#FF6600, byte values, memory addresses, MAC addresses, and Unicode code points such as U+00E9.
Tool description
This tool converts whole numbers between binary, octal, decimal, and hexadecimal. Every number base converter here works the same way, from the general Number Base Converter to the ones for a single pair, such as decimal to binary or hexadecimal to decimal: it starts on the bases in its name, and the Source and Target menus switch to any of the four. Type or paste a number and the result appears as you type, ready to copy. A digit the base doesn't have, such as a 2 in a binary number, shows an error. The swap button turns the conversion around.
How it works
The tool reads the number as a JavaScript BigInt, an integer with no size limit, so 64-bit values and longer ones convert exactly, without rounding: FFFFFFFFFFFFFFFF in hexadecimal is 18446744073709551615 in decimal. It accepts:
- A minus sign in front, which the result keeps: -42 in decimal is -101010 in binary.
- The prefixes used in code:
0bfor binary,0ofor octal, and0xfor hexadecimal, so0x1Fconverts to 31. - Spaces and underscores between groups of digits, such as
1111 0000or1_000_000. - Hexadecimal letters in upper or lower case. Results are written in upper case.
Only whole numbers convert, so a number with a decimal point shows an error.