{
  "schemaVersion": 1,
  "slug": "length-calculator",
  "category": "conversion",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "f0889fb338fed82a7c64195949db92dbef0fd097e0881d4f749114a4a7bb45d3",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/length-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": "result = value × F[from] ÷ F[to]; F: mm → 0.001, cm → 0.01, m → 1, km → 1000, in → 0.0254, ft → 0.3048, yd → 0.9144, mi → 1609.344",
    "vars": [
      [
        "value",
        "length amount"
      ],
      [
        "from",
        "source unit"
      ],
      [
        "to",
        "target unit"
      ],
      [
        "F",
        "metres per unit (lookup table)"
      ],
      [
        "result",
        "converted length"
      ]
    ],
    "note": "All values are converted through metres; feet value = metres ÷ 0.3048."
  },
  "externalEvidence": {
    "reviewedAt": "2026-10-04",
    "sources": [
      {
        "name": "NIST SP 811 — Conversion factors by quantity",
        "url": "https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors/nist-guide-si-appendix-b9"
      }
    ],
    "basis": "Convert lengths via metres using the selected international-unit factors.",
    "limitations": "Only the displayed unit definitions are converted; rounding and measurement uncertainty are separate.",
    "implementationHash": "f0889fb338fed82a7c64195949db92dbef0fd097e0881d4f749114a4a7bb45d3",
    "domain": "conversion"
  },
  "contract": {
    "compute": "const units={\"mm\":\"mm\",\"cm\":\"cm\",\"m\":\"m\",\"km\":\"km\",\"in\":\"in\",\"ft\":\"ft\",\"yd\":\"yd\",\"mi\":\"mi\"}, factors={\"mm\":0.001,\"cm\":0.01,\"m\":1,\"km\":1000,\"in\":0.0254,\"ft\":0.3048,\"yd\":0.9144,\"mi\":1609.344}; if(!Number.isFinite(value)||value<-1000000000000||value>1000000000000||!Object.prototype.hasOwnProperty.call(units,from)||!Object.prototype.hasOwnProperty.call(units,to))return {\"result\":null,\"inMetres\":null,\"inFeet\":null,\"__error\":\"inputError\"}; const out=(function(){const F={mm:0.001,cm:0.01,m:1,km:1000,in:0.0254,ft:0.3048,yd:0.9144,mi:1609.344}; const metres=value*F[from]; return { result: metres/F[to], inMetres: metres, inFeet: metres/0.3048 };})(); if(out.__error)return {...{\"result\":null,\"inMetres\":null,\"inFeet\":null},...out}; out.__resultUnit=units[to]; out.__unitRatio=factors[to]/factors[from]; return out;",
    "inputs": [
      {
        "name": "value",
        "type": "number",
        "default": 1,
        "min": -1000000000000,
        "max": 1000000000000,
        "step": 0.01,
        "requiredValue": true,
        "strictRange": true
      },
      {
        "name": "from",
        "type": "select",
        "default": "m",
        "options": [
          {
            "value": "m"
          },
          {
            "value": "mm"
          },
          {
            "value": "cm"
          },
          {
            "value": "km"
          },
          {
            "value": "in"
          },
          {
            "value": "ft"
          },
          {
            "value": "yd"
          },
          {
            "value": "mi"
          }
        ]
      },
      {
        "name": "to",
        "type": "select",
        "default": "ft",
        "options": [
          {
            "value": "ft"
          },
          {
            "value": "mm"
          },
          {
            "value": "cm"
          },
          {
            "value": "m"
          },
          {
            "value": "km"
          },
          {
            "value": "in"
          },
          {
            "value": "yd"
          },
          {
            "value": "mi"
          }
        ]
      },
      {
        "name": "precision",
        "type": "select",
        "default": 4,
        "options": [
          {
            "value": 0
          },
          {
            "value": 2
          },
          {
            "value": 4
          },
          {
            "value": 6
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "result",
        "precision": 4,
        "unit": "",
        "precisionField": "precision",
        "unitField": "__resultUnit",
        "trimTrailingZeros": true,
        "notation": "auto"
      },
      {
        "name": "inMetres",
        "precision": 6,
        "unit": "m",
        "showWhen": {
          "to": [
            "mm",
            "cm",
            "km",
            "in",
            "ft",
            "yd",
            "mi"
          ]
        },
        "notation": "auto"
      },
      {
        "name": "inFeet",
        "precision": 6,
        "unit": "ft",
        "showWhen": {
          "to": [
            "mm",
            "cm",
            "m",
            "km",
            "in",
            "yd",
            "mi"
          ]
        },
        "notation": "auto"
      }
    ],
    "interpret": null
  }
}
