{
  "schemaVersion": 1,
  "slug": "hex-decimal-calculator",
  "category": "math",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "3feadbaabe99b3320053221bc9a2549fcfc4daeef26c666272d0bfb72439be7a",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/hex-decimal-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "n = Σ d_k×16^k; bytes = ceil(hex_digits/2)",
    "vars": [
      [
        "d_k",
        "hex digit value (0–15)"
      ],
      [
        "k",
        "position from the right, starting at 0"
      ],
      [
        "digits",
        "number of hex digits"
      ]
    ],
    "note": "Decimal value is parsed exactly within JavaScript’s safe integer range. Hex digits count includes leading zeros; whole-byte capacity = ceil(digits/2)."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const raw = String(hex).trim().replace(/^0x/i,''); if (!raw || !/^[0-9a-fA-F]+$/.test(raw)) return { decimal: null, binary: null, octal: null, digits: null, bytes: null, __error: 'inputError' }; const big = BigInt('0x' + raw); if (big > BigInt(Number.MAX_SAFE_INTEGER)) return { decimal: null, binary: null, octal: null, digits: null, bytes: null, __error: 'inputError' }; const n = Number(big); return { decimal: n, binary: big.toString(2), octal: big.toString(8), digits: raw.length, bytes: Math.ceil(raw.length/2) };",
    "inputs": [
      {
        "name": "hex",
        "type": "text",
        "default": "FF",
        "step": 1
      }
    ],
    "outputs": [
      {
        "name": "decimal",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "binary",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "octal",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "digits",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "bytes",
        "precision": 0,
        "unit": ""
      }
    ],
    "interpret": null
  }
}
