DEC2OCT in Excel: Pad Octal Fields and Inspect Thirty-Bit Negatives
Convert decimal integers to octal in Excel, check leading-zero widths and preserve quantities through signed thirty-bit round trips.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: DEC2OCT(number,[places]) converts a decimal integer to octal notation. Nonnegative results can be padded with leading zeros; negative values use ten octal characters representing a thirty-bit two’s-complement number.
Availability and version history
- Introduced: the first introduction version is not established by the reviewed official history.
- Availability: official help lists Excel for Microsoft 365, Excel for Microsoft 365 for Mac, Excel 2024, Excel 2024 for Mac, Excel 2021, Excel 2021 for Mac, Excel 2019, Excel 2016.
- Checked: October 14, 2026; official DEC2OCT reference. Documentation and independent models; no native Excel execution or wider platform certification.
Syntax and documented range
=DEC2OCT(number,[places])
The input interval is −536870912 through 536870911, or −2^29 through 2^29−1. Microsoft documents #NUM! outside that interval and #VALUE! for a nonnumeric number argument.
Places is optional. Omission uses the minimum necessary character count. Too few places produces #NUM!; fractional places is truncated, nonnumeric places produces #VALUE!, and negative places produces #NUM!. The dedicated page does not separately settle zero places or fractional-number coercion.
For negative values, places is ignored and the result contains ten octal characters. The examples use valid positive widths when supplying that argument to a negative number, without claiming precedence for invalid combinations.
Example 1: create fixed-width base-eight labels
Enter 0, 8, 45, 101 and 416 in A2:A6. In B2 enter =DEC2OCT(A2) and in C2 enter =DEC2OCT(A2,4), then fill down.
| Decimal | Minimum octal | Width 4 |
|---|---|---|
| 0 | 0 | 0000 |
| 8 | 10 | 0010 |
| 45 | 55 | 0055 |
| 101 | 145 | 0145 |
| 416 | 640 | 0640 |
Octal 55 represents 5×8+5=45. Octal 640 represents 6×64+4×8=416. Padding changes the field’s appearance, not the quantity.
In D2 use =OCT2DEC(C2) and fill down. The expected results return to the original decimal inputs. OCT2DEC performs base-eight interpretation explicitly; digit-only output should not be mistaken for the original decimal value.
Example 2: examine the signed boundary
| Formula | Expected octal |
|---|---|
=DEC2OCT(-1) |
7777777777 |
=DEC2OCT(-8) |
7777777770 |
=DEC2OCT(-100) |
7777777634 |
=DEC2OCT(-536870912) |
4000000000 |
=DEC2OCT(536870911) |
3777777777 |
The −100 row is also a documented Microsoft control. Independently, adding 2^30 gives 1073741724, which is octal 7777777634. Decoding the thirty-bit signed representation subtracts 2^30 again.
A negative value is not shown as a minus sign followed by its ordinary positive octal magnitude. =DEC2OCT(-8,3) still returns 7777777770, not −010 or a three-character signed field.
The positive endpoint begins with 3 and the negative endpoint begins with 4 because each octal digit encodes three bits. The highest bit changes at that boundary.
Advanced example: separate a three-digit layout into fields
Suppose a data file defines three independent octal digits, each an integer 0–7. Enter 6, 4 and 0 in F2:H2. Their packed decimal quantity is:
=F2*64+G2*8+H2
The expected value is 416. Converting it with =DEC2OCT(416,3) produces 640, matching the three-digit layout. The weights are 8^2, 8^1 and 8^0.
For digits 0, 0 and 7, the packed quantity is 7 and a width-three conversion gives 007. Omitting padding would give 7 and lose the visible field boundaries, even though the numeric quantity stays correct.
This example defines its own data layout. It does not imply that every three-digit octal code is one quantity to add, or that an application assigns the same meaning to each digit.
Advanced check: perform arithmetic on quantities
Decimal 45 plus decimal 8 gives 53. Their octal representations are 55 and 10; the representation of the sum is 65.
=DEC2OCT(OCT2DEC("55")+OCT2DEC("10"),3)
The expected output is 065. Decode first so the arithmetic clearly uses quantities, then re-encode with the required width. Ordinary decimal interpretation of 55+10 would give 65 as a decimal quantity, which happens to look like the intended octal digits but has a different meaning. That coincidence is not a valid calculation method.
A second control makes the error visible: decimal 7+1=8, whose octal form is 10. Ordinary addition of the octal-looking digit strings 7 and 1 instead gives 8, which is not even a valid octal digit. Decode, calculate and re-encode rather than relying on coincidentally matching characters.
Errors and related converters
=DEC2OCT(101,2) needs three characters and follows the documented #NUM! rule. Places 4.9 is truncated to 4 and gives 0145. A larger width does not make an out-of-range decimal input valid.
DEC2BIN and DEC2HEX have different signed input intervals. Do not assume one conversion family’s limits apply to another. Native numeric-text coercion, fractional source handling and undocumented width/error boundaries remain untested.
References and verification
Expected outputs are independently calculated examples or documented rules, not captured native Excel results. Formulas use English function names and comma argument separators. Locale, rendering and boundary restrictions are stated where relevant.