Contact

DEC2HEX in Apple Numbers: Decimal to Hexadecimal with Padding

Engineering Intermediate Apple Numbers

Convert decimal integers to hexadecimal with Apple Numbers DEC2HEX, including positive examples, 8-digit negative results, padding, and errors.

Verification status: Official documentation referenced; example outcomes independently reasoned or arithmetically checked where stated. Not executed in Apple Numbers. How formula examples are checked

Quick answer: =DEC2HEX(100) produces 64, because 100 decimal equals 6×16+4. To display a minimum of four characters, Apple’s official example =DEC2HEX("1001",4) produces 03E9. Negative inputs require particular care: Apple publishes =DEC2HEX(-100) → FFFFFF9C, an eight-character two’s-complement result. Apple DEC2HEX (checked 2026-10-13).

Verification: Apple documentation and independent arithmetic were checked. Expected results were not produced by running Numbers; official examples are identified separately. No native application execution or screenshots were performed.

What the function does—and what it does not

Represent a decimal integer in base 16, with optional minimum-length zero padding for a fixed-width hexadecimal label. A positional numeral conversion changes how a quantity is written, not its magnitude: binary uses powers of 2, decimal powers of 10, and hexadecimal powers of 16.

Exact Apple-documented argument order:

=DEC2HEX(decimal-string, convert-length)
Argument Required? Official value type/default/bounds Practical meaning
decimal-string Required Apple describes a string with digits 0–9, but explicitly demonstrates numeric 100, quoted "1001" and the signed numeric example -100. Decimal input. The signed example is a documented exception to the prose description of digits only.
convert-length Optional Number, 0–12 inclusive; omitted defaults to 1. Minimum hexadecimal output width, with leading zeros when needed. Do not assume a shorter width truncates the result.

This signature and its range come from Apple’s DEC2HEX reference (edition 15.4, checked 2026-10-13). In Apple’s English-language examples the arguments are separated with a comma; use the function editor to check the correct separator for your document’s locale before pasting a formula from another region. No argument may be silently swapped with another conversion function’s parameter order.

Reproduce the formulas in a Numbers table

Create a table named Conversions. Set column A’s header to Meaning, B’s header to Input, and C’s header to Result. Enter the following inputs in B2:B7. Set input cells to Text for hex/binary identifiers and for any value where leading zeroes matter. Put the corresponding formula in C2:C7. The examples assume the formula and the referenced cells belong to the same table, so ordinary B2 syntax applies. For references across tables or sheets, use the names generated by Numbers’ reference picker rather than blindly copying an Excel Sheet!B2 formula; see Apple’s reference guidance.

Row B input Formula in C Expected visible result Manual audit
2 100 =DEC2HEX(B2) 64 6×16+4 = 100
3 255 =DEC2HEX(B3) FF 15×16+15 = 255
4 16 =DEC2HEX(B4) 10 1×16+0 = 16
5 4095 =DEC2HEX(B5) FFF 15×256+15×16+15 = 4095
6 0 =DEC2HEX(B6) 0 Zero stays zero
7 1001 =DEC2HEX(B7,4) 03E9 1001 = 3×256+14×16+9; pad 3E9 to 4 digits

Evidence boundary: If a formula is also one of Apple’s literal examples, the source is identified in this guide. Otherwise the displayed result is an independently calculated expectation, not a screenshot or an execution log. To test on your own Mac, enter the exact inputs, use the formula editor, and compare cell C to the expected result without changing source formatting.

Understanding the conversion step by step

For 1001 decimal: 1001 ÷ 16 = 62 remainder 9; 62 ÷ 16 = 3 remainder 14 (E); 3 ÷ 16 = 0 remainder 3. Read remainders backward to obtain 3E9. The optional four-character minimum yields 03E9. For 4095, use 15×256 + 15×16 + 15 = 4095, hence FFF. Hexadecimal digits A–F represent decimal 10–15; they are not case-sensitive alphabet labels for numerical calculation.

Apple’s negative example: =DEC2HEX(-100) yields FFFFFF9C in the reference. The manual 32-bit two’s-complement computation is (2^32−100)=4294967196, which equals FFFFFF9C in base 16. However this arithmetic does not establish unlisted input-range limits for Numbers.

Advanced use: fixed-width device register identifiers

Imagine six integer register values for a controller: 0, 16, 100, 255, 1001, 4095. With a common four-character display width, their independently derived hexadecimal labels are respectively 0000, 0010, 0064, 00FF, 03E9, 0FFF. In Numbers, put those numbers in the data column and use =DEC2HEX(B2,4) in the result column, then fill down. This is suitable for human-readable documentation where uniform widths help scanning.

Do not treat a four-character display as a restriction on the numeric value: Apple’s description of convert-length says it requests a minimum length. Likewise, a padded representation can be text-like in downstream tools. Before exporting identifiers, test whether other applications preserve leading zeros in the saved file type; the Apple help page does not specify CSV type-round-tripping.

Why does a negative number have eight characters?

Apple documents two’s complement and says that negative results are always eight hexadecimal characters. For its -100 example, the 32-bit value 2^32−100 is 4294967196, which equals hexadecimal FFFFFF9C. This independently validates the published example, not the behavior of every negative integer or software release. The argument prose (“only digits from 0 through 9”) and signed example contradict a literal interpretation of the string description; where they conflict, quote Apple’s explicit working example rather than inventing unsupported coercion rules. Apple DEC2HEX.

Errors, limits and troubleshooting

  • A decimal input containing letters such as "12A", a 0x prefix, or thousands separators conflicts with Apple’s decimal-input description. The precise native error code was not tested.
  • The convert-length rule is 0–12, unlike BIN2HEX’s 1–12; applying the wrong bound is a common copy/paste mistake.
  • convert-length 13 or a negative width is outside the documented range; use an accepted width and verify your case.
  • A minimum width smaller than the natural output length is not a request for truncation; Apple says minimum. Do not assume Excel’s #NUM! rule transfers to Numbers.
  • Apple’s negative example is -100, not a blanket guarantee about arbitrary signed inputs. Exact overflow bounds and conversion of text "-100" were not natively verified.
  • A decimal fraction such as 3.5 is not part of the documented decimal-digit sample domain; avoid inferring rounding/truncation without a Numbers test.
  • On imported source data, prefer a numeric cell or explicit decimal text. Avoid applying date, currency or scientific formats where the visible value might obscure the underlying input.

Error-label caution: Apple’s checked DEC2HEX page states some invalid-input conditions but does not establish a complete mapping of all faults to displayed error names. This guide deliberately distinguishes a documented invalid case from a native test result, which has not been obtained.

Apple Numbers versus Excel: use source-specific rules

Excel also has a DEC2HEX function but Microsoft documents 10-character two’s-complement hexadecimal results for negative integers, including -54 → FFFFFFFFCA. Apple instead publishes eight-character negative output for -100. These are different signed conventions; DEC2HEX(-100) must not be assumed to round-trip identically between applications. Microsoft’s input range and Excel error labels are Excel-only facts, not Apple Numbers rules. Microsoft Excel DEC2HEX; Apple DEC2HEX.

A formula that appears identical in both products can still accept a different numeric range, padding parameter and signed representation. Test critical imported workbooks in their destination app before relying on conversion output.

Version and platform guidance

The formula signature and examples here are verified from Apple Formulas and Functions Help, version 15.4, checked 2026-10-13. Apple’s Mac version history lists Numbers 15.4 and says Numbers 15.4 for Mac requires macOS 26 or later. That release note does not establish when this particular engineering function first shipped. No native execution was performed on Numbers for Mac, iPad or iPhone; availability in older versions, behavior after importing from Excel, exact error-label localization, and output data types in exported files remain unverified. Follow the in-app function browser for your installed version rather than assuming the same signature applies to all editions.

For localized function entry, the formulas above use English function names and commas as Apple presents them in its English Help. Decimal separator, argument separator and display formatting can differ with document language/region; confirm formula tokens in the function editor. Do not mistake commas inside quoted text for separators.

Official sources and validation

  • [A1] Apple DEC2HEX — official syntax, input types, width/default rules, examples and any explicit signed note; checked 2026-10-13; Apple Formulas and Functions Help 15.4.
  • [A2] Apple cell references — reference syntax and table-scoped formula workflow; checked 2026-10-13.
  • [A3] Apple Numbers Mac version history — 15.4 release summary and macOS requirement; checked 2026-10-13.
  • [M1] Independent base-conversion audit using Python integer arithmetic (base 2/10/16), with expected results recorded by formula in the evidence JSON; calculations are not native Numbers formula execution.
  • [C1] Microsoft Excel function reference linked above: compatibility comparison only. Its limits, errors, and negative encoding are not evidence about Numbers.

Limitations: Native Numbers execution, localized entry, signed/overflow boundaries and exported value types were not tested. Validate critical workflows in the target app.