DEC2OCT function
Converts a decimal number to octal (base-8) text, such as 58 to "72". Negatives come back as 10-digit two's complement.
Available in Excel 2007 and later (Excel 2003 needed the Analysis ToolPak add-in), Microsoft 365, Excel for the web, Excel for Mac
Excel 2007 and laterWorks in Google Sheets
Syntax
DEC2OCT(number, [places])| Argument | What it means | |
|---|---|---|
number | Required | The decimal whole number to convert, from -536,870,912 to 536,870,911. Decimals are truncated. |
places | Optional | Minimum number of characters, padded with leading zeros. Ignored for negative numbers. |
Returns: Text containing octal digits 0–7.
How DEC2OCT works
DEC2OCT writes a decimal number in octal, the base-8 system that uses only the digits 0 to 7. Octal is less common than hex today, but you still meet it in Unix and Linux file permissions (chmod 755), some older aviation and industrial systems, and computing courses. Each octal digit represents exactly three bits.
The output is text. Use places for a fixed width, such as 3 for a permission triple. Negative numbers come back as 10 octal digits in two's complement (30 bits): -1 becomes 7777777777, and places is ignored for them. Numbers outside about ±536.9 million return #NUM!; the reverse conversion is OCT2DEC.
Examples
1Convert to octal with padding
| A | B | |
|---|---|---|
| 1 | Decimal | |
| 2 | 58 | 072 |
Result: 072
58 = 7×8 + 2, so the octal form is 72; places = 3 pads it to 072.
2Unix permission bits
| A | B | |
|---|---|---|
| 1 | Permission value | |
| 2 | 493 | 755 |
Result: 755
A program reported the file mode as 493 in decimal. In octal that is 755: read, write and execute for the owner, read and execute for everyone else.
3A negative number
| A | B | |
|---|---|---|
| 1 | Decimal | |
| 2 | -100 | 7777777634 |
Result: 7777777634
Excel adds 2^30 to -100 and writes the result in octal, giving the 10-digit two's-complement form 7777777634.
Common errors and how to fix them
| Error | Why it happens | Fix |
|---|---|---|
#NUM! | The number is out of range, the result needs more digits than places, or places is negative. | Increase places or use =BASE(number, 8) for large positive numbers. |
#VALUE! | An argument is non-numeric text. | Convert the input with VALUE. |
Tips
- Each octal digit is three bits, so
=DEC2BIN(A2, 9)and=DEC2OCT(A2, 3)show the same permission pattern in two ways. - For positive numbers larger than the limit,
=BASE(number, 8)works up to 2^53.
Google Sheets
DEC2OCT also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.
DEC2OCT in other languages
In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.
| Language | Function name |
|---|---|
| Danish | DEC.TIL.OKT |
| Dutch | DEC.N.OCT |
| Finnish | DESOKT |
| French | DECOCT |
| German | DEZINOKT |
| Hungarian | DEC.OKT |
| Italian | DECIMALE.OCT |
| Norwegian (Bokmål) | DESTILOKT |
| Polish | DZIES.NA.ÓSM |
| Portuguese (Brazil) | DECAOCT |
| Portuguese (Portugal) | DECAOCT |
| Russian | ДЕС.В.ВОСЬМ |
| Spanish | DEC.A.OCT |
| Swedish | DEC.TILL.OKT |