Contact

DEC2OCT in Google Sheets: Encode Decimal Values and Pack Octal Fields

Engineering Intermediate Google Sheets

Create padded octal labels in Google Sheets, calculate with decimal quantities and keep the documented negative-endpoint inconsistency explicit.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

Quick answer: DEC2OCT(decimal_number,[significant_digits]) converts a decimal quantity to signed octal. Supply a width for fixed-size positive labels, and retain the original numeric quantity for calculations.

Availability and version history

  • Introduced: first introduction date is not established by the reviewed official history; no desktop release number is inferred.
  • Availability: documented in the rolling Google Sheets service; these examples use the web worksheet workflow.
  • Checked: October 14, 2026; official DEC2OCT reference. Documentation and independent models, with no native Sheets execution or wider client certification.

Syntax and the documented endpoint conflict

=DEC2OCT(decimal_number,[significant_digits])

Google accepts a decimal string or a valid numeric input converted to its corresponding string. Its example shows numeric 199 and text “199” producing the same octal representation, 307.

The optional width pads a nonnegative result with leading zeros. Too few positions produces documented #NUM!. The width is ignored for negative inputs. Fractional input truncation and unusual width values are not established by this reference, so the examples use integer quantities and positive integer widths.

The page lists a positive maximum of 536870911 but prints a negative minimum of −53687092. That negative number is inconsistent with the thirty-bit signed octal model in Google’s OCT2DEC reference, whose mathematical minimum is −2^29, or −536870912. This guide does not silently correct the admission limit or certify either disputed boundary in native Sheets. Its negative controls are modest values inside both stated intervals.

Example 1: create a fixed-width export field

Enter the quantities in A2:A6. In B2 use =DEC2OCT(A2,4) and in C2 use =OCT2DEC(B2), filling both down.

A, quantity B, octal label C, decoded check
0 0000 0
9 0011 9
26 0032 26
73 0111 73
365 0555 365

Octal 32 is 3×8+2=26. Octal 555 is 5×64+5×8+5=365. Leading zeros add field width without changing either quantity.

In D2 use =A2=C2 and fill down. All five checks are TRUE. Keep A numeric for totals; B is the representation intended for an interface or report.

Example 2: inspect small negative encodings

Formula Expected thirty-bit octal
=DEC2OCT(-1,4) 7777777777
=DEC2OCT(-8,4) 7777777770
=DEC2OCT(-42,4) 7777777726

These outputs are independently calculated from the paired decoder’s thirty-bit two’s-complement model. For −42, add 2^30 to the quantity, obtaining 1073741782, then write that value in ten octal positions.

The supplied four-position width does not shorten a negative output. =OCT2DEC("7777777726") checks the signed quantity −42; an ordinary decimal interpretation of those ten displayed digits would be unrelated.

These controls do not settle the reference’s inconsistent lowest permitted DEC2OCT input. Boundary acceptance and unspecified combined-error precedence remain untested.

Advanced example: pack three small fields

Suppose an export format contains three independent fields, each from zero through seven. Enter 5, 5 and 5 in E2:G2. Combine them numerically in H2:

=E2*64+F2*8+G2

The result is 365. In I2 use =DEC2OCT(H2,3), producing 555. Each octal digit holds one three-bit field.

For a second record, enter 1, 6 and 3 in E3:G3. The quantity is 115 and the label is 163. These are weighted positions, not ordinary decimal concatenation.

Validate each field before packing. A last field of eight is invalid for this layout: 1×64+6×8+8=120, whose octal label 170 carries into the middle position. The converter cannot know that the original record violated a field-size rule.

Advanced example: avoid arithmetic on encoded labels

With quantity 73 in A5, B5 contains 0111. Adding decimal nine directly to that label produces decimal 120, while the intended quantity is 82. Encode the numeric total instead:

=DEC2OCT(A5+9,3)

Expected result: 122. If only the label is available, use =DEC2OCT(OCT2DEC(B5)+9,3). Both routes preserve the intended base meaning.

This distinction matters even when an incorrect calculation looks plausible. Octal 120 represents 80, so a result containing only valid octal digits can still be wrong.

Width and input checks

=DEC2OCT(365,2) needs three digits and follows the documented #NUM! rule. Use OCT2HEX when an existing octal representation must become hexadecimal; do not feed the octal-looking digits into DEC2OCT as though they were the original decimal quantity.

The page does not establish a complete nonnumeric/coercion/error matrix. Actual blanks, numeric text, fractional numbers and invalid widths should be checked separately in the intended Sheets workflow rather than inferred from another application.

References and verification

Examples use fictional data, English function names and comma separators. Expected outputs are independent mathematical calculations or explicitly documented rules, not native Sheets captures. Check the spreadsheet locale when reproducing punctuation-sensitive formulas.