{
  "schemaVersion": 1,
  "slug": "cm-inches-calculator",
  "category": "conversion",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "0073a9b12804082904af86826337d20ffc08c7ea3bbd425542d0def16ce89710",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/cm-inches-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": "in = cm ÷ 2.54; cm = in × 2.54",
    "vars": [
      [
        "cm",
        "length in centimetres"
      ],
      [
        "in",
        "length in inches"
      ]
    ],
    "note": "1 inch is exactly 2.54 cm; the metres output is cm ÷ 100."
  },
  "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": "1 in = 2.54 cm.",
    "limitations": "Only the displayed unit definitions are converted; rounding and measurement uncertainty are separate.",
    "implementationHash": "0073a9b12804082904af86826337d20ffc08c7ea3bbd425542d0def16ce89710",
    "domain": "conversion"
  },
  "contract": {
    "compute": "const F={cm:0.01,in:0.0254,m:1,km:1000,ft:0.3048}; const source=direction==='cm2in'?'cm':direction==='in2cm'?'in':from, target=direction==='cm2in'?'in':direction==='in2cm'?'cm':to; if (!Number.isFinite(value) || value < -1e9 || value > 1e9 || !Object.prototype.hasOwnProperty.call(F,source) || !Object.prototype.hasOwnProperty.call(F,target)) return { __error: 'inputError', result: null, feet: null, metres: null, __resultUnit: null }; const metres=value*F[source], inches=metres/0.0254, roundedTenths=Math.round(Math.abs(inches)*10), ft=Math.floor(roundedTenths/120), rem=(roundedTenths-ft*120)/10, sign=inches<0?'-':''; return {result:value*(F[source]/F[target]), __resultUnit:target, __unitRatio:F[target]/F[source], feet:sign+ft+' ft '+rem.toFixed(1)+' in', metres};",
    "inputs": [
      {
        "name": "value",
        "type": "number",
        "default": 30,
        "min": -1000000000,
        "max": 1000000000,
        "step": "any",
        "requiredValue": true,
        "strictRange": true,
        "unitField": "from",
        "unitLabels": {
          "cm": "cm",
          "in": "in",
          "m": "m",
          "km": "km",
          "ft": "ft"
        }
      },
      {
        "name": "direction",
        "type": "select",
        "default": "auto",
        "options": [
          {
            "value": "auto"
          },
          {
            "value": "cm2in"
          },
          {
            "value": "in2cm"
          }
        ],
        "showWhen": {
          "from": []
        }
      },
      {
        "name": "precision",
        "type": "select",
        "default": 4,
        "options": [
          {
            "value": 0
          },
          {
            "value": 2
          },
          {
            "value": 4
          },
          {
            "value": 6
          }
        ]
      },
      {
        "name": "from",
        "type": "select",
        "default": "cm",
        "options": [
          {
            "value": "cm"
          },
          {
            "value": "in"
          },
          {
            "value": "m"
          },
          {
            "value": "km"
          },
          {
            "value": "ft"
          }
        ]
      },
      {
        "name": "to",
        "type": "select",
        "default": "in",
        "options": [
          {
            "value": "in"
          },
          {
            "value": "cm"
          },
          {
            "value": "m"
          },
          {
            "value": "km"
          },
          {
            "value": "ft"
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "result",
        "precision": 4,
        "unit": "",
        "unitField": "__resultUnit",
        "precisionField": "precision",
        "trimTrailingZeros": true,
        "notation": "auto"
      },
      {
        "name": "feet",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "metres",
        "precision": 4,
        "unit": "m",
        "trimTrailingZeros": true,
        "showWhen": {
          "to": [
            "cm",
            "in",
            "km",
            "ft"
          ]
        },
        "notation": "auto"
      }
    ],
    "interpret": null
  }
}
