{
  "schemaVersion": 1,
  "slug": "octal-decimal-calculator",
  "category": "math",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "a9058469fadc8c95bf4d640f316ee9b3776c8bf5d61b567692224baf975ba948",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/octal-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": "D = Σ_{i=0}^{k−1} d_i × 8^i",
    "vars": [
      [
        "D",
        "decimal value"
      ],
      [
        "d_i",
        "octal digit 0–7"
      ],
      [
        "i",
        "position from right"
      ],
      [
        "k",
        "number of digits"
      ]
    ],
    "note": "Characters outside 0–7 are stripped before conversion; binary and hex are the base-2 and base-16 forms of D; empty input gives 0."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const raw=String(octal).trim();if(!/^[0-7]+$/.test(raw))return{decimal:null,binary:null,hex:null,digits:null,__error:'inputError'};const n=parseInt(raw,8);if(!Number.isSafeInteger(n))return{decimal:null,binary:null,hex:null,digits:null,__error:'inputError'};return{decimal:n,binary:n.toString(2),hex:n.toString(16).toUpperCase(),digits:raw.length}",
    "inputs": [
      {
        "name": "octal",
        "type": "text",
        "default": "755",
        "step": 1
      }
    ],
    "outputs": [
      {
        "name": "decimal",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "binary",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "hex",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "digits",
        "precision": 0,
        "unit": ""
      }
    ],
    "interpret": null
  }
}
