{
  "category": "Math and trigonometry functions",
  "display_name": "TRUNC",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.TRUNC",
  "implementation_state": {
    "answer_bank": {
      "excel_builds": [
        "20430"
      ],
      "larger_numeric": 236,
      "last_bit": 321,
      "matched": 50760,
      "other_mismatch": 0,
      "refused": 0,
      "rows": 51317,
      "unread": 0,
      "worst_ulp": 86
    },
    "detail": "Of 51,465 recorded answers (51,317 in the answer bank and 148 workbook cells), 557 do not match: 236 differ by more than 16 ULP, 321 differ by at most 16 ULP.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "differs",
    "state_label": "Known larger differences",
    "summary": "Known larger differences on 557 of 51,465 recorded answers",
    "workbook_corpus": {
      "cells": 148,
      "matched": 148
    }
  },
  "implementations": [
    {
      "commit": "9e1884369a678158dd82d3d74188daf986995e87",
      "flavour": "excel-compatibility-candidate",
      "language": "Rust",
      "name": "CalcFunc",
      "own_code": [
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/rounding.rs#L107-L107",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/rounding.rs#L230-L243"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/rounding::call",
        "catalogue/rounding::numeric",
        "catalogue/rounding::numbers",
        "catalogue/rounding::abs",
        "catalogue/rounding::reading",
        "catalogue/rounding::flush",
        "catalogue/rounding::whole_reading",
        "catalogue/rounding::stored",
        "catalogue/rounding::directed_places",
        "catalogue/rounding::directed",
        "catalogue/rounding::directed_initial_underflow",
        "decimal::low32",
        "decimal::Natural::zero",
        "decimal::Natural::from_u64",
        "decimal::Natural::pow10",
        "decimal::Natural::normalize",
        "decimal::Natural::is_zero",
        "decimal::Natural::mul_add_small",
        "decimal::Natural::add_one",
        "decimal::Natural::times_pow10",
        "decimal::Natural::times_pow5",
        "decimal::Natural::times_pow2",
        "decimal::Natural::add",
        "decimal::Natural::subtract",
        "decimal::Natural::bit_len",
        "decimal::Natural::bit",
        "decimal::Natural::pow2",
        "decimal::Natural::from_u128",
        "decimal::Natural::to_u128",
        "decimal::Natural::shift_in",
        "decimal::Natural::div_rem",
        "decimal::Natural::div_small",
        "decimal::Natural::digits",
        "decimal::Natural::cmp",
        "decimal::ExactDecimal::read",
        "decimal::ExactDecimal::fifteen",
        "decimal::ExactDecimal::unit",
        "decimal::ExactDecimal::magnitude",
        "decimal::ExactDecimal::fifteen_x87",
        "decimal::ExactDecimal::normalized",
        "decimal::ExactDecimal::binary",
        "decimal::ExactDecimal::round_at",
        "decimal::round_to_64_bits",
        "decimal::truncate"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/rounding.rs#L107-L107",
      "state": "differs",
      "suite": null,
      "summary": "Known larger differences on 557 of 51,465 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.TRUNC.json",
  "name": "TRUNC",
  "notes": [
    {
      "basis": "Under the family rules the recorded rows match ROUND 36,821 of 36,945, ROUNDUP 52,022 of 52,841, ROUNDDOWN 59,182 of 59,995 and TRUNC 50,504 of 51,317, with no row lost and each remaining failure classified in the write-up.",
      "documentation": null,
      "evidence": [
        {
          "commit": "ab94fb91a50fbdf89bdb2dac0e12fcd77a5e5f82",
          "locator": null,
          "note": "the rules in the product; the commit message carries the row counts",
          "path": "crates/calc-func/src/catalogue/rounding.rs",
          "repository": "DnaCalc"
        },
        {
          "commit": "b5d84a80a5a4640eca9ce04f232c0bc115503f34",
          "locator": null,
          "note": "research write-up: full-bank result, the rules, what stays open",
          "path": "content/notes/evidence/2026-11-04/rounding-EVIDENCE.md",
          "repository": "ExcelFunctionsHandbook"
        }
      ],
      "functions": [
        "FUNC.ROUND",
        "FUNC.ROUNDDOWN",
        "FUNC.ROUNDUP",
        "FUNC.TRUNC"
      ],
      "inferred": null,
      "kind": "excel-differs-from-math",
      "note_id": "FN-ROUND-002",
      "open": [
        "How the scale is formed for |n| > 27: a single correctly rounded 64-bit power and the chained multiplications tried do not fit; 123 ROUND, 548 ROUNDUP, 556 ROUNDDOWN and 555 TRUNC rows remain.",
        "The reading step itself: one control at n = -10 misses the single RN64 step by just over half a unit, so that step is an approximation of the real one even for |n| <= 27. It stays because it gains rows and loses none."
      ],
      "recorded_on": "2026-11-04",
      "repros": [
        {
          "call": "ROUND(-1594628480062905, 14)",
          "correct": {
            "bits": "0xc316a939806956e4",
            "display": "-1594628480062905",
            "how": "An integer rounded to 14 places is itself.",
            "kind": "number"
          },
          "excel": {
            "bits": "0xc316a939806956d0",
            "display": "-1594628480062900",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "number",
              "value": {
                "bits": "0xc316a939806956e4",
                "display": "-1594628480062905",
                "kind": "number"
              }
            },
            {
              "name": "num_digits",
              "value": {
                "bits": "0x402c000000000000",
                "display": "14",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, AMD Ryzen 7 4800H",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "line 3758, key ROUND|0xc316a939806956e4|0x402c000000000000",
            "note": null,
            "path": "cache/oracle-20430/build-20430/ROUND.jsonl.gz",
            "repository": "CalcFunc-Evidence"
          }
        },
        {
          "call": "ROUNDDOWN(283025097725723.5, 0)",
          "correct": {
            "bits": "0x42f0168ea69971b0",
            "display": "283025097725723",
            "how": "ROUNDDOWN drops the fraction .5.",
            "kind": "number"
          },
          "excel": {
            "bits": "0x42f0168ea69971c0",
            "display": "283025097725724",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "number",
              "value": {
                "bits": "0x42f0168ea69971b8",
                "display": "283025097725723.5",
                "kind": "number"
              }
            },
            {
              "name": "num_digits",
              "value": {
                "bits": "0x0000000000000000",
                "display": "0",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, AMD Ryzen 7 4800H",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "line 753, key ROUNDDOWN|0x42f0168ea69971b8|0x0000000000000000",
            "note": null,
            "path": "cache/oracle-20430/build-20430/ROUNDDOWN.jsonl.gz",
            "repository": "CalcFunc-Evidence"
          }
        }
      ],
      "schema": "efh.function-note/v1",
      "statement": "Before choosing a digit these functions read the number to 15 significant digits on the x87 unit: with e the decimal exponent and n = 14 - e, y = RN64(|x| * 10^n), or RN64(|x| / 10^-n) when n is negative, while 10^|n| is exact in 64 bits (|n| <= 27). A half in y goes up for ROUNDDOWN, ROUNDUP and TRUNC and down for ROUND. So digits beyond the 15th are lost even when the requested precision keeps them: ROUND(-1594628480062905,14) loses its last digit, and ROUNDDOWN(283025097725723.5,0) returns 283025097725724, larger than its input.",
      "status": "measured",
      "title": "The rounding functions read 15 digits first, so ROUNDDOWN can round up"
    },
    {
      "basis": "One Excel workbook read cell by cell through Value2 on 2026-11-04, saved, reopened and recalculated; rows from the rounding write-up, 627 of 627.",
      "documentation": null,
      "evidence": [
        {
          "commit": "ab94fb91a50fbdf89bdb2dac0e12fcd77a5e5f82",
          "locator": null,
          "note": "the rules in the product; the commit message carries the row counts",
          "path": "crates/calc-func/src/catalogue/rounding.rs",
          "repository": "DnaCalc"
        },
        {
          "commit": "b5d84a80a5a4640eca9ce04f232c0bc115503f34",
          "locator": "cells A1..A4, B1..B24, reopened, recalculated",
          "note": "cell-by-cell Excel reading of the NaN patterns",
          "path": "content/notes/evidence/2026-11-04/round-nan-downstream.json",
          "repository": "ExcelFunctionsHandbook"
        },
        {
          "commit": "b5d84a80a5a4640eca9ce04f232c0bc115503f34",
          "locator": null,
          "note": "the script that took the reading",
          "path": "content/notes/evidence/2026-11-04/round-nan-downstream.ps1",
          "repository": "ExcelFunctionsHandbook"
        },
        {
          "commit": "b5d84a80a5a4640eca9ce04f232c0bc115503f34",
          "locator": null,
          "note": "the sheet as Excel saved it",
          "path": "content/notes/evidence/2026-11-04/round-nan-downstream-sheet1.xml",
          "repository": "ExcelFunctionsHandbook"
        },
        {
          "commit": "b5d84a80a5a4640eca9ce04f232c0bc115503f34",
          "locator": null,
          "note": "research write-up: full-bank result, the rules, what stays open",
          "path": "content/notes/evidence/2026-11-04/rounding-EVIDENCE.md",
          "repository": "ExcelFunctionsHandbook"
        }
      ],
      "functions": [
        "FUNC.ROUND",
        "FUNC.ROUNDDOWN",
        "FUNC.ROUNDUP",
        "FUNC.TRUNC"
      ],
      "inferred": "That one decimal-to-binary conversion routine is the source of all these patterns is inferred from the exponent-overflow encoding.",
      "kind": "excel-differs-from-math",
      "note_id": "FN-ROUND-003",
      "open": [
        "How these patterns sort among themselves and with other numbers, and display width, are not recorded."
      ],
      "recorded_on": "2026-11-04",
      "repros": [
        {
          "call": "ROUND(1.7976931348623157E+308, 0)",
          "correct": {
            "bits": "0x7fefffffffffffff",
            "display": "1.7976931348623157e+308",
            "how": "DBL_MAX is an integer, so rounding it to 0 places returns it.",
            "kind": "number"
          },
          "excel": {
            "bits": "0x7ff000000000000a",
            "display": "NaN bit pattern, shown as 1.8E+308",
            "kind": "nonfinite"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "number",
              "value": {
                "bits": "0x7fefffffffffffff",
                "display": "1.7976931348623157e+308",
                "kind": "number"
              }
            },
            {
              "name": "num_digits",
              "value": {
                "bits": "0x0000000000000000",
                "display": "0",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20527, Windows; bitness and CPU not recorded in this reading",
          "source": {
            "commit": "b5d84a80a5a4640eca9ce04f232c0bc115503f34",
            "locator": "cells.A3",
            "note": null,
            "path": "content/notes/evidence/2026-11-04/round-nan-downstream.json",
            "repository": "ExcelFunctionsHandbook"
          }
        },
        {
          "call": "ROUND(1.7976931348623157E+308, -307)",
          "correct": {
            "bits": null,
            "display": "#NUM!",
            "how": "The rounded value exceeds the largest binary64; Excel reports overflow in its own arithmetic as #NUM!.",
            "kind": "error"
          },
          "excel": {
            "bits": "0x7ff005419221015d",
            "display": "NaN bit pattern, shown as 1.8E+308",
            "kind": "nonfinite"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "number",
              "value": {
                "bits": "0x7fefffffffffffff",
                "display": "1.7976931348623157e+308",
                "kind": "number"
              }
            },
            {
              "name": "num_digits",
              "value": {
                "bits": "0xc073300000000000",
                "display": "-307",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20527, Windows; bitness and CPU not recorded in this reading",
          "source": {
            "commit": "b5d84a80a5a4640eca9ce04f232c0bc115503f34",
            "locator": "cells.A2",
            "note": null,
            "path": "content/notes/evidence/2026-11-04/round-nan-downstream.json",
            "repository": "ExcelFunctionsHandbook"
          }
        },
        {
          "call": "ROUND(1.7976931348623157E+308, -308)",
          "correct": {
            "bits": null,
            "display": "#NUM!",
            "how": "The rounded value exceeds the largest binary64; Excel reports overflow in its own arithmetic as #NUM!.",
            "kind": "error"
          },
          "excel": {
            "bits": "0x7ff1ccf385ebc8a0",
            "display": "NaN bit pattern, shown as 2E+308",
            "kind": "nonfinite"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "number",
              "value": {
                "bits": "0x7fefffffffffffff",
                "display": "1.7976931348623157e+308",
                "kind": "number"
              }
            },
            {
              "name": "num_digits",
              "value": {
                "bits": "0xc073400000000000",
                "display": "-308",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20527, Windows; bitness and CPU not recorded in this reading",
          "source": {
            "commit": "b5d84a80a5a4640eca9ce04f232c0bc115503f34",
            "locator": "cells.A1",
            "note": null,
            "path": "content/notes/evidence/2026-11-04/round-nan-downstream.json",
            "repository": "ExcelFunctionsHandbook"
          }
        }
      ],
      "schema": "efh.function-note/v1",
      "statement": "ROUND of a number near 1.8E308 can return a binary64 with an all-ones exponent field. A decimal result of 2^1024 or more keeps its 53-bit significand, and its exponent is carried into the exponent field without a check, so the bits are a NaN. ROUND, ROUNDDOWN and TRUNC return those bits; ROUNDUP gives #NUM!. The recorded rows hold 430 such ROUND rows, 102 ROUNDDOWN and 95 TRUNC, and all 627 follow this. Even ROUND(DBL_MAX,0), whose answer is DBL_MAX, returns 0x7ff000000000000a. The cell shows 2E+308 or 1.8E+308, and a pattern with its sign bit set shows 2E+308 too, with no minus. ISNUMBER gives TRUE, ISERROR FALSE, TYPE 1, ERROR.TYPE #N/A; A1=A1 and A1>0 are TRUE. =A1, N(A1), MAX(A1), ABS(A1) and IFERROR(A1,...) pass the pattern on, as does =-A1 with its sign unchanged. Arithmetic on it (A1+0, A1*1, A1-A1, SUM, ROUND) gives #NUM!, and TEXT(A1,\"0\") gives #VALUE!. Saved to .xlsx, each such cell is written as the error #NUM!; reopened, the cells read #NUM! until a full recalculation brings the patterns back.",
      "status": "measured",
      "title": "Near DBL_MAX, ROUND returns NaN bit patterns that Excel treats as numbers"
    },
    {
      "basis": "Under the family rules the recorded rows match ROUND 36,821 of 36,945, ROUNDUP 52,022 of 52,841, ROUNDDOWN 59,182 of 59,995 and TRUNC 50,504 of 51,317, with no row lost and each remaining failure classified in the write-up. All 13,914 informative ROUNDDOWN and TRUNC rows with large num_digits follow the rule.",
      "documentation": null,
      "evidence": [
        {
          "commit": "ab94fb91a50fbdf89bdb2dac0e12fcd77a5e5f82",
          "locator": null,
          "note": "the rules in the product; the commit message carries the row counts",
          "path": "crates/calc-func/src/catalogue/rounding.rs",
          "repository": "DnaCalc"
        },
        {
          "commit": "b5d84a80a5a4640eca9ce04f232c0bc115503f34",
          "locator": null,
          "note": "research write-up: full-bank result, the rules, what stays open",
          "path": "content/notes/evidence/2026-11-04/rounding-EVIDENCE.md",
          "repository": "ExcelFunctionsHandbook"
        }
      ],
      "functions": [
        "FUNC.ROUNDDOWN",
        "FUNC.ROUNDUP",
        "FUNC.TRUNC"
      ],
      "inferred": null,
      "kind": "excel-differs-from-math",
      "note_id": "FN-ROUNDUP-001",
      "open": [],
      "recorded_on": "2026-11-04",
      "repros": [
        {
          "call": "ROUNDUP(1.234567890123456e-200, 65536)",
          "correct": {
            "bits": "0x166e3d71f622be8f",
            "display": "1.234567890123456e-200",
            "how": "The exact decimal expansion of this binary64 number has fewer than 32768 places, so a truncation at num_digits places returns the number itself.",
            "kind": "number"
          },
          "excel": {
            "bits": "0x3ff0000000000000",
            "display": "1",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "number",
              "value": {
                "bits": "0x166e3d71f622be8f",
                "display": "1.234567890123456e-200",
                "kind": "number"
              }
            },
            {
              "name": "num_digits",
              "value": {
                "bits": "0x40f0000000000000",
                "display": "65536",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, CPU not recorded in this capture",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "w111roundcount-ROUNDUP-00041",
            "note": null,
            "path": "runs/w111-rounding-count-refinement-20260929/answers-roundup.json.gz",
            "repository": "CalcFunc-Evidence"
          }
        },
        {
          "call": "ROUNDUP(1.234567890123456e-200, 65537)",
          "correct": {
            "bits": "0x166e3d71f622be8f",
            "display": "1.234567890123456e-200",
            "how": "The exact decimal expansion of this binary64 number has fewer than 32768 places, so a truncation at num_digits places returns the number itself.",
            "kind": "number"
          },
          "excel": {
            "bits": "0x3fb999999999999a",
            "display": "0.1",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "number",
              "value": {
                "bits": "0x166e3d71f622be8f",
                "display": "1.234567890123456e-200",
                "kind": "number"
              }
            },
            {
              "name": "num_digits",
              "value": {
                "bits": "0x40f0001000000000",
                "display": "65537",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, CPU not recorded in this capture",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "w111roundcount-ROUNDUP-00043",
            "note": null,
            "path": "runs/w111-rounding-count-refinement-20260929/answers-roundup.json.gz",
            "repository": "CalcFunc-Evidence"
          }
        },
        {
          "call": "ROUNDUP(1.234567890123456e-200, 32768)",
          "correct": {
            "bits": "0x166e3d71f622be8f",
            "display": "1.234567890123456e-200",
            "how": "The exact decimal expansion of this binary64 number has fewer than 32768 places, so a truncation at num_digits places returns the number itself.",
            "kind": "number"
          },
          "excel": {
            "bits": "0x0000000000000000",
            "display": "0",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "number",
              "value": {
                "bits": "0x166e3d71f622be8f",
                "display": "1.234567890123456e-200",
                "kind": "number"
              }
            },
            {
              "name": "num_digits",
              "value": {
                "bits": "0x40e0000000000000",
                "display": "32768",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, CPU not recorded in this capture",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "w111roundcount-ROUNDUP-00033",
            "note": null,
            "path": "runs/w111-rounding-count-refinement-20260929/answers-roundup.json.gz",
            "repository": "CalcFunc-Evidence"
          }
        },
        {
          "call": "TRUNC(1.234567890123456e-200, 65536)",
          "correct": {
            "bits": "0x166e3d71f622be8f",
            "display": "1.234567890123456e-200",
            "how": "The exact decimal expansion of this binary64 number has fewer than 32768 places, so a truncation at num_digits places returns the number itself.",
            "kind": "number"
          },
          "excel": {
            "bits": "0x0000000000000000",
            "display": "0",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "number",
              "value": {
                "bits": "0x166e3d71f622be8f",
                "display": "1.234567890123456e-200",
                "kind": "number"
              }
            },
            {
              "name": "num_digits",
              "value": {
                "bits": "0x40f0000000000000",
                "display": "65536",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, CPU not recorded in this capture",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "w111roundcount-TRUNC-00041",
            "note": null,
            "path": "runs/w111-rounding-count-refinement-20260929/answers-trunc.json.gz",
            "repository": "CalcFunc-Evidence"
          }
        }
      ],
      "schema": "efh.function-note/v1",
      "statement": "ROUNDUP, ROUNDDOWN and TRUNC take the digit count from the low 16 bits of the integer part of |num_digits|, with the sign of num_digits. If |num_digits| is 2^32 or more, or those low bits are 32768 or more, the truncation happens at 100 places (10^-100, or 10^100 for a negative count). So 65536 acts as 0, 65537 as 1, 32768 to 65535 as 100, and -2147483748, whose low 16 bits are 100, as -100. In the out-of-range case ROUNDUP adds no unit for a positive count, and gives #NUM! for a negative count when a digit is dropped.",
      "status": "measured",
      "title": "ROUNDUP, ROUNDDOWN and TRUNC read num_digits from its low 16 bits"
    },
    {
      "basis": "Recorded rows of the broad capture; counts from the rounding write-up.",
      "documentation": null,
      "evidence": [
        {
          "commit": "b5d84a80a5a4640eca9ce04f232c0bc115503f34",
          "locator": null,
          "note": "research write-up: full-bank result, the rules, what stays open",
          "path": "content/notes/evidence/2026-11-04/rounding-EVIDENCE.md",
          "repository": "ExcelFunctionsHandbook"
        }
      ],
      "functions": [
        "FUNC.ROUNDDOWN",
        "FUNC.ROUNDUP",
        "FUNC.TRUNC"
      ],
      "inferred": null,
      "kind": "excel-differs-from-math",
      "note_id": "FN-TRUNC-001",
      "open": [
        "Why this one input converts 3 steps below nearest."
      ],
      "recorded_on": "2026-11-04",
      "repros": [
        {
          "call": "TRUNC(2.2250738585072014e-308, 0)",
          "correct": {
            "bits": "0x0000000000000000",
            "display": "0",
            "how": "DBL_MIN is below 1, so truncating it at 0 or 1 places gives 0.",
            "kind": "number"
          },
          "excel": {
            "bits": "0x000ffffffffffffa",
            "display": "2.2250738585071984e-308",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "number",
              "value": {
                "bits": "0x0010000000000000",
                "display": "2.2250738585072014e-308",
                "kind": "number"
              }
            },
            {
              "name": "num_digits",
              "value": {
                "bits": "0x0000000000000000",
                "display": "0",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, CPU not recorded in this capture",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "w111broad-20260929-TRUNC-00026",
            "note": null,
            "path": "runs/w111-broad-20260929/answers/answers-trunc.json.gz",
            "repository": "CalcFunc-Evidence"
          }
        },
        {
          "call": "TRUNC(2.2250738585072014e-308, 1)",
          "correct": {
            "bits": "0x0000000000000000",
            "display": "0",
            "how": "DBL_MIN is below 1, so truncating it at 0 or 1 places gives 0.",
            "kind": "number"
          },
          "excel": {
            "bits": "0x000ffffffffffffa",
            "display": "2.2250738585071984e-308",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "number",
              "value": {
                "bits": "0x0010000000000000",
                "display": "2.2250738585072014e-308",
                "kind": "number"
              }
            },
            {
              "name": "num_digits",
              "value": {
                "bits": "0x3ff0000000000000",
                "display": "1",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, CPU not recorded in this capture",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "w111broad-20260929-TRUNC-00027",
            "note": null,
            "path": "runs/w111-broad-20260929/answers/answers-trunc.json.gz",
            "repository": "CalcFunc-Evidence"
          }
        }
      ],
      "schema": "efh.function-note/v1",
      "statement": "With DBL_MIN (0x0010000000000000) as number, TRUNC, ROUNDDOWN and ROUNDUP return the subnormal 0x000ffffffffffffa at each num_digits recorded, so TRUNC(DBL_MIN,0) is not 0. That value is 6 steps below DBL_MIN and 3 steps below 0x000ffffffffffffd, the binary64 nearest the 15-digit reading 2.22507385850720E-308. The recorded rows hold 256 such cases for each of the three functions. ROUND gives 0 on the same inputs.",
      "status": "measured",
      "title": "TRUNC of DBL_MIN returns a subnormal, not 0"
    }
  ],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n[ROUND](FUNC.ROUND.md) chooses a nearest decimal; [MROUND](FUNC.MROUND.md) chooses a multiple. [INT](FUNC.INT.md) rounds negatives downward; [ROUNDDOWN](FUNC.ROUNDDOWN.md) makes the digit count explicit.\n\n\n\n\n",
    "how-to-implement": "\nThe current worksheet wrapper reads numeric arguments in order and flushes subnormal numeric operands to zero. Return zero for a zero `number` before finding its decimal exponent. The following steps start with a finite, nonzero admitted input. The [stored-arithmetic chapter](../model/09-staged-arithmetic.md) explains exact binary decoding and significand rounding.\n\nFirst construct the number’s fifteen-significant-digit **reading**. Extract the exact binary64 value and find its decimal exponent `e` by comparisons with exact powers of ten, so `10^e <= abs(x) < 10^(e+1)`. Put `s=14-e`. When `abs(s)<=27`, evaluate `abs(x)*10^s` (or `abs(x)/10^(-s)`) with a 64-bit significand and extended exponent range, rounding to nearest/even. **Do not store that scaled value to binary64 before the integer decision.** Round it to an integer: exact halves go down for ROUND’s reading, up for the directed functions’ readings. Retain the sign and the exact decimal value `integer*10^(-s)`.\n\nThis reading step is a measured reconstruction with a known counterexample even inside the stated scale range. For `abs(s)>27`, Excel’s scaling is still open; the current code falls back to exact binary64-to-decimal rounding to fifteen digits. That fallback is a candidate, not an identified Excel stage.\n\n1. Truncate the magnitude of `num_digits` and retain its low sixteen bits, then restore the sign. Magnitudes at least `2^32`, or low bits at least `32768`, select an out-of-range sentinel of 100 places with the original sign.\n2. Before digit rounding, check the special initial-reading return described below. If it applies, return its packed result immediately. Otherwise truncate the exact decimal reading at unit `10^(-D)`, then convert that truncation to nearest binary64, using the [overflow packing exception](../model/09-staged-arithmetic.md#decimal-family-packing-exceptions) when required.\n3. Return that stored truncation without adding a unit. Flush final subnormal results to zero, apart from the special initial-reading path below.\n\nWorked: `x=-7.29`, `D=1` retains 72 tenths of the magnitude and restores the negative sign, giving `-7.2`. A count of `65537` uses low bits equal to one, so it selects the same decimal position. This conversion rule is distinct from ROUND’s signed 32-bit count.\n\nThe current boundary reconstruction handles a normal input below twice the minimum normal value whose initial reading becomes subnormal: convert twice the reading (a normal number) and decrement its encoded exponent field by one, retaining the sign and significand. This reproduces the observed packing rather than an ordinary subnormal conversion. Other final subnormals still flush. The large-scale reading and remaining last-bit discrepancies stay open; consult the dated failure breakdown.\n\n\n",
    "quirks": "\nThe recorded functions first read fifteen significant decimal digits. Asking to retain more digits can therefore change an input that mathematically needs no rounding. The recorded `ROUNDDOWN(283025097725723.5,0)` returns `283025097725724`, showing that the preliminary reading can move the number upward before truncation. Huge digit counts have recorded integer-conversion behaviour rather than a simple “keep everything” rule. Near the normal-range boundary and overflow, worksheet publication needs separate handling.\n\n\nThe exact-cell minimum normal input `0x0010000000000000` has a recorded early return of `0x000ffffffffffffa`, even at zero requested digits. That return happens before ordinary digit rounding. At the upper end, the current model can publish a tagged NaN bit pattern as a worksheet number. See the [packing rules and worked encodings](../model/09-staged-arithmetic.md#decimal-family-packing-exceptions).\n\n\n",
    "sources": "\n- [Microsoft: TRUNC function](https://support.microsoft.com/en-us/excel/functions/trunc-function), opened 6 November 2026; syntax, documented argument rules and errors.\n- [DnaCalc implementation](https://github.com/DnaCalc/DnaCalc/blob/da3ecc4fb19a3a5529708c311d0e8f05688ac165/crates/calc-func/src/catalogue/rounding.rs); implementation steps and the limits identified in the text.\n- [Rounding research](../notes/evidence/2026-11-04/rounding-EVIDENCE.md): measured reading, count rules, overflow and remaining failures.\n\n",
    "try-it": "\n`=TRUNC(-7.29,1)` returns `-7.2`; `=TRUNC(-7.29)` returns `-7`. INT of the same negative input would return `-8`.\n\n\n",
    "version-differences": "The recorded environments below distinguish a reading from a same-input comparison. Counts describe captured inputs in each environment; overlapping captures and comparisons are not totals of unique worksheet calls.\n\n| Excel 16.0 build | Platform and CPU | Captured inputs |\n|---|---|---:|\n| 19929 | Windows, bitness not recorded, CPU not recorded | 43 |\n| 20430 | Windows, 64-bit, CPU not recorded | 51,317 |\n\nThe record contains no same-input comparison between these environments. Reading different inputs on different builds does not establish either a version change or cross-build agreement.\n\n[Recorded environments and comparison details](https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.TRUNC.json).\n\nRetained controls from the indexed captures:\n\n| Build and recorded CPU | Captured call or arguments | Excel result |\n|---|---|---|\n| 19929, CPU not recorded | [`=TRUNC(0)`](https://github.com/DnaCalc/CalcFunc-Evidence/blob/4287ba192d2e3a7fd54671ea1cee1c34cb2e84e2/runs/W097-R-B-validation-cellref-module/comparisons/excel_sample_comparisons.jsonl.gz) | `0.0` (`0x0000000000000000`) |\n| 20430, CPU not recorded | [`TRUNC(1,0)`](https://github.com/DnaCalc/CalcFunc-Evidence/blob/4287ba192d2e3a7fd54671ea1cee1c34cb2e84e2/cache/w111-broad-regenerated-20260929/answers-trunc.json.gz) | `1` (`0x3ff0000000000000`) |\n\nThese are earlier recorded answers, not new Excel runs or an additional cross-build comparison. The function JSON retains each source locator, exact argument bits where available, and input-route status. Call notation does not imply that captured binary64 values were entered as decimal formula literals.",
    "what-it-does": "\n`TRUNC(number, [num_digits])` rounds toward zero by removing digits beyond the requested precision. Positive digit counts address places after the decimal point, zero the integer position, and negative counts places to its left. TRUNC defaults to zero digits.\n\n\n"
  },
  "signature": {
    "display": "TRUNC(number, [num_digits])",
    "parameters": [
      {
        "description": null,
        "name": "number",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "num_digits",
        "optional": true,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 2,
        "min": 1
      },
      "category": "Math and trigonometry functions",
      "classification": {
        "arg_preparation_profile": "ValuesOnlyPreAdapter",
        "coercion_lift_profile": "Custom",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "None",
        "fec_dependency_profile": "None",
        "host_interaction_class": "None",
        "kernel_signature_class": "NumsToNum",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "RefOnly",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "Number cut to a number of digits by dropping the rest",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Truncates a number to an integer",
        "microsoft_url": "https://support.microsoft.com/en-us/office/trunc-function-8b86a64c-3127-43db-ba14-aa5ceb292721"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "TRUNC"
        },
        {
          "locale": "bg-BG",
          "name": "TRUNC"
        },
        {
          "locale": "cs-CZ",
          "name": "USEKNOUT"
        },
        {
          "locale": "da-DK",
          "name": "AFKORT"
        },
        {
          "locale": "de-DE",
          "name": "TRUNC"
        },
        {
          "locale": "el-GR",
          "name": "TRUNC"
        },
        {
          "locale": "en-AU",
          "name": "TRUNC"
        },
        {
          "locale": "en-GB",
          "name": "TRUNC"
        },
        {
          "locale": "en-US",
          "name": "TRUNC"
        },
        {
          "locale": "es-ES",
          "name": "TRUNCAR"
        },
        {
          "locale": "et-EE",
          "name": "TRUNC"
        },
        {
          "locale": "fi-FI",
          "name": "KATKAISE"
        },
        {
          "locale": "fr-FR",
          "name": "TRONQUE*"
        },
        {
          "locale": "he-IL",
          "name": "TRUNC"
        },
        {
          "locale": "hr-HR",
          "name": "TRUNC"
        },
        {
          "locale": "hu-HU",
          "name": "CSONK"
        },
        {
          "locale": "id-ID",
          "name": "TRUNC"
        },
        {
          "locale": "it-IT",
          "name": "TRUNC"
        },
        {
          "locale": "ja-JP",
          "name": "TRUNC"
        },
        {
          "locale": "ko-KR",
          "name": "TRUNC"
        },
        {
          "locale": "lt-LT",
          "name": "TRUNC"
        },
        {
          "locale": "lv-LV",
          "name": "TRUNC"
        },
        {
          "locale": "nb-NO",
          "name": "AVKORT"
        },
        {
          "locale": "nl-NL",
          "name": "GEHEEL"
        },
        {
          "locale": "pl-PL",
          "name": "LICZBA.CAŁK"
        },
        {
          "locale": "pt-BR",
          "name": "TRUNC"
        },
        {
          "locale": "pt-PT",
          "name": "TRUNCAR"
        },
        {
          "locale": "ro-RO",
          "name": "TRUNC"
        },
        {
          "locale": "ru-RU",
          "name": "ОТБР"
        },
        {
          "locale": "sk-SK",
          "name": "TRUNC"
        },
        {
          "locale": "sl-SI",
          "name": "TRUNC"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "TRUNC"
        },
        {
          "locale": "sv-SE",
          "name": "AVKORTA"
        },
        {
          "locale": "th-TH",
          "name": "TRUNC"
        },
        {
          "locale": "tr-TR",
          "name": "NSAT işlevi"
        },
        {
          "locale": "uk-UA",
          "name": "TRUNC"
        },
        {
          "locale": "vi-VN",
          "name": "TRUNC"
        },
        {
          "locale": "zh-CN",
          "name": "TRUNC"
        },
        {
          "locale": "zh-HK",
          "name": "TRUNC"
        },
        {
          "locale": "zh-TW",
          "name": "TRUNC"
        }
      ],
      "signature": {
        "display": "TRUNC(number, [num_digits])",
        "parameters": [
          {
            "description": null,
            "name": "number",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "num_digits",
            "optional": true,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "TRUNC",
      "version_marker": null,
      "xlcall": {
        "code": "197",
        "symbol": "xlfTrunc"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/trunc-function-8b86a64c-3127-43db-ba14-aa5ceb292721"
  },
  "try_it": {
    "formula": "=TRUNC(-7.29,1)"
  },
  "url": "https://handbook.dnacalc.com/functions/TRUNC.html",
  "variants": [],
  "versions": [
    {
      "behaviour": "TRUNC(1.234567890123456e-200, 65536) returned 0 (0x0000000000000000). TRUNC(2.2250738585072014e-308, 0) returned 2.2250738585071984e-308 (0x000ffffffffffffa). 1 further recorded control is attached. Inputs were supplied through cells using Value2. These are controls from this environment, not a same-input comparison with another build.",
      "excel_build": "16.0 build 20430",
      "observations": [
        {
          "call": "TRUNC(1.234567890123456e-200, 65536)",
          "excel": {
            "bits": "0x0000000000000000",
            "display": "0",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "number",
              "value": {
                "bits": "0x166e3d71f622be8f",
                "display": "1.234567890123456e-200",
                "kind": "number"
              }
            },
            {
              "name": "num_digits",
              "value": {
                "bits": "0x40f0000000000000",
                "display": "65536",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, CPU not recorded in this capture"
        },
        {
          "call": "TRUNC(2.2250738585072014e-308, 0)",
          "excel": {
            "bits": "0x000ffffffffffffa",
            "display": "2.2250738585071984e-308",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "number",
              "value": {
                "bits": "0x0010000000000000",
                "display": "2.2250738585072014e-308",
                "kind": "number"
              }
            },
            {
              "name": "num_digits",
              "value": {
                "bits": "0x0000000000000000",
                "display": "0",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, CPU not recorded in this capture"
        },
        {
          "call": "TRUNC(2.2250738585072014e-308, 1)",
          "excel": {
            "bits": "0x000ffffffffffffa",
            "display": "2.2250738585071984e-308",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "number",
              "value": {
                "bits": "0x0010000000000000",
                "display": "2.2250738585072014e-308",
                "kind": "number"
              }
            },
            {
              "name": "num_digits",
              "value": {
                "bits": "0x3ff0000000000000",
                "display": "1",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, CPU not recorded in this capture"
        }
      ],
      "platform": "Windows 64-bit, CPU not recorded in this capture",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/3345a87/content/notes/FN-ROUNDUP-001.json",
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/3345a87/content/notes/FN-TRUNC-001.json"
      ]
    },
    {
      "behaviour": "43 captured inputs are indexed for this environment. Capture dates are not recorded. This is a reading count, not a comparison with another build. Retained control =TRUNC(0) returned 0.0 (0x0000000000000000). The selected archive row does not record its input plumbing; no input route is inferred.",
      "excel_build": "16.0 build 19929",
      "observations": [
        {
          "call": "=TRUNC(0)",
          "excel": {
            "bits": "0x0000000000000000",
            "display": "0.0",
            "kind": "number"
          },
          "input_route": "not-recorded",
          "inputs": [],
          "recorded_in": "Excel 16.0 build 19929, Windows, bitness not recorded, CPU not recorded.",
          "source": {
            "commit": "4287ba192d2e3a7fd54671ea1cee1c34cb2e84e2",
            "locator": "BSE-000000158",
            "path": "runs/W097-R-B-validation-cellref-module/comparisons/excel_sample_comparisons.jsonl.gz",
            "repository": "CalcFunc-Evidence"
          }
        }
      ],
      "platform": "Windows, bitness not recorded, CPU not recorded",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.TRUNC.json",
        "https://github.com/DnaCalc/CalcFunc-Evidence/blob/4287ba192d2e3a7fd54671ea1cee1c34cb2e84e2/runs/W097-R-B-validation-cellref-module/comparisons/excel_sample_comparisons.jsonl.gz"
      ]
    },
    {
      "behaviour": "51,317 captured inputs are indexed for this environment. Capture dates: 2026-09-29 to 2026-09-29. This is a reading count, not a comparison with another build. Retained control TRUNC(1,0) returned 1 (0x3ff0000000000000). The capture specifies exact-double bulk Value2 cell input.",
      "excel_build": "16.0 build 20430",
      "observations": [
        {
          "call": "TRUNC(1,0)",
          "excel": {
            "bits": "0x3ff0000000000000",
            "display": "1",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "argument1",
              "value": {
                "bits": "0x3ff0000000000000",
                "display": "1",
                "kind": "number"
              }
            },
            {
              "name": "argument2",
              "value": {
                "bits": "0x0000000000000000",
                "display": "0",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows, 64-bit, CPU not recorded.",
          "source": {
            "commit": "4287ba192d2e3a7fd54671ea1cee1c34cb2e84e2",
            "locator": "w111broad-20260929-TRUNC-00074",
            "path": "cache/w111-broad-regenerated-20260929/answers-trunc.json.gz",
            "repository": "CalcFunc-Evidence"
          }
        }
      ],
      "platform": "Windows, 64-bit, CPU not recorded",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.TRUNC.json",
        "https://github.com/DnaCalc/CalcFunc-Evidence/blob/4287ba192d2e3a7fd54671ea1cee1c34cb2e84e2/cache/w111-broad-regenerated-20260929/answers-trunc.json.gz"
      ]
    }
  ]
}