{
  "schemaVersion": 1,
  "slug": "significant-figures-calculator",
  "category": "math",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "f269d469422d0fee322ab17bcea096a10297d86059017434b456d615a45abc4a",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/significant-figures-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": "e = ⌊log₁₀|v|⌋; r = round(v×10^(n−1−e))÷10^(n−1−e)",
    "vars": [
      [
        "v",
        "Input value"
      ],
      [
        "n",
        "Significant figures"
      ],
      [
        "e",
        "Order of magnitude"
      ],
      [
        "r",
        "Rounded value"
      ]
    ],
    "note": "Scientific notation v ≈ r×10^e; decimal places = max(n−1−e, 0); for v = 0 every result is 0."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const v=value;if(v===0)return{rounded:0,orderOfMagnitude:0,scientificNotation:'0',decimalPlaces:0};const exp=Math.floor(Math.log10(Math.abs(v)));const factor=Math.pow(10,figures-1-exp);const rounded=Math.sign(v)*Math.round(Math.abs(v)*factor)/factor;const roundedExp=Math.floor(Math.log10(Math.abs(rounded)));return{rounded,orderOfMagnitude:roundedExp,scientificNotation:rounded.toExponential(figures-1),decimalPlaces:Math.max(figures-1-roundedExp,0)};",
    "inputs": [
      {
        "name": "value",
        "type": "number",
        "default": 0.00456789,
        "min": -1000000000000000,
        "max": 1000000000000000,
        "step": 1e-9
      },
      {
        "name": "figures",
        "type": "number",
        "default": 3,
        "min": 1,
        "max": 15,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "rounded",
        "precision": 10,
        "unit": ""
      },
      {
        "name": "orderOfMagnitude",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "scientificNotation",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "decimalPlaces",
        "precision": 0,
        "unit": ""
      }
    ],
    "interpret": null
  }
}
