{
  "schemaVersion": 1,
  "slug": "binary-decimal-calculator",
  "category": "math",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "f0a36a8890eed3c3f48275b2025f9e4422127fcf811dfd8d888ce08c6e0e4954",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/binary-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 = Σ b_k × 2^k",
    "vars": [
      [
        "b_k",
        "Binary digit (0 or 1)"
      ],
      [
        "k",
        "Position from the right, starting at 0"
      ],
      [
        "n",
        "Decimal value"
      ]
    ],
    "note": "Characters other than 0 and 1 are stripped; hexadecimal and octal come from base conversion; 1 hex digit = 4 bits; bytes = bits/8."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const raw=String(binary==null?'':binary).trim(); if(!/^[01]+$/.test(raw)||raw.length>4096)return{decimal:null,hex:null,octal:null,bits:null,bytes:null,__error:'inputError'}; const n=BigInt('0b'+raw); return{decimal:n.toString(),hex:n.toString(16).toUpperCase(),octal:n.toString(8),bits:raw.length,bytes:Math.ceil(raw.length/8)};",
    "inputs": [
      {
        "name": "binary",
        "type": "text",
        "default": "11111111",
        "step": 1
      }
    ],
    "outputs": [
      {
        "name": "decimal",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "hex",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "octal",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "bits",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "bytes",
        "precision": 2,
        "unit": ""
      }
    ],
    "interpret": null
  }
}
