{
  "schemaVersion": 1,
  "slug": "mph-kmh-calculator",
  "category": "conversion",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "e2a30bb31bb31b1488c73c01461afc1710ed264fd23f2bf25d71fc35fce45034",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/mph-kmh-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": "v(km/h) = v(mph) × 1.609344; m/s = km/h ÷ 3.6",
    "vars": [
      [
        "v_m",
        "speed in mph"
      ],
      [
        "v_k",
        "speed in km/h"
      ],
      [
        "v_s",
        "speed in m/s"
      ]
    ],
    "note": "The factor 1.609344 is exact; the direction switch converts back to mph by division."
  },
  "externalEvidence": {
    "reviewedAt": "2026-10-28",
    "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 mph = 1.609344 km/h. P1 consolidation retains the core model and adds input modes or derived outputs. The migration report records the input/output union and known-answer checks.",
    "limitations": "Only the displayed unit definitions are converted; rounding and measurement uncertainty are separate. Added display totals and migration adapters are implementation behavior, not independently validated claims.",
    "implementationHash": "e2a30bb31bb31b1488c73c01461afc1710ed264fd23f2bf25d71fc35fce45034",
    "domain": "conversion"
  },
  "contract": {
    "compute": "const mergedResult=(()=>{if(([].includes(String(from))&&![\"auto\", \"mph2kmh\", \"kmh2mph\"].includes(String(direction)))||(true&&![\"0\", \"2\", \"4\", \"6\"].includes(String(precision)))||(true&&![\"mph\", \"kmh\"].includes(String(from)))||(true&&![\"kmh\", \"mph\"].includes(String(to))))return{__error:'inputError'};\nif((true&&(!Number.isFinite(value)||value<-1000000000||value>1000000000)))return{__error:'inputError'};\nconst F={\"mph\":1,\"kmh\":0.621371192237334}, U={\"mph\":\"mph\",\"kmh\":\"km/h\"}, L={\"mph2kmh\":[\"mph\",\"kmh\"],\"kmh2mph\":[\"kmh\",\"mph\"]}; const pair=Object.prototype.hasOwnProperty.call(L,direction)?L[direction]:[from,to], source=pair[0], target=pair[1]; if(!Number.isFinite(value)||value<-1000000000||value>1000000000||!Object.prototype.hasOwnProperty.call(F,source)||!Object.prototype.hasOwnProperty.call(F,target))return {\"result\":null,\"kmh\":null,\"mph\":null,\"mps\":null,\"__error\":\"inputError\"}; const base=value*F[source], out=(function(value,direction){const mph = direction === 'mph2kmh' ? value : value/1.609344; const kmh = mph*1.609344; return { result: direction === 'mph2kmh' ? kmh : mph, kmh, mph, mps: kmh/3.6 };})(base/F[\"mph\"],\"mph2kmh\"); if(out.__error)return {...{\"result\":null,\"kmh\":null,\"mph\":null,\"mps\":null},...out}; out.result=value*(F[source]/F[target]);out.__resultUnit=U[target];out.__unitRatio=F[target]/F[source];return out;\n})();return mergedResult.__error?{\"result\":null,\"kmh\":null,\"mph\":null,\"mps\":null,...mergedResult}:mergedResult;",
    "inputs": [
      {
        "name": "value",
        "type": "number",
        "default": 60,
        "min": -1000000000,
        "max": 1000000000,
        "step": 0.1,
        "requiredValue": true,
        "strictRange": true
      },
      {
        "name": "direction",
        "type": "select",
        "default": "auto",
        "options": [
          {
            "value": "auto"
          },
          {
            "value": "mph2kmh"
          },
          {
            "value": "kmh2mph"
          }
        ],
        "showWhen": {
          "from": []
        }
      },
      {
        "name": "precision",
        "type": "select",
        "default": 4,
        "options": [
          {
            "value": 0
          },
          {
            "value": 2
          },
          {
            "value": 4
          },
          {
            "value": 6
          }
        ]
      },
      {
        "name": "from",
        "type": "select",
        "default": "mph",
        "options": [
          {
            "value": "mph"
          },
          {
            "value": "kmh"
          }
        ]
      },
      {
        "name": "to",
        "type": "select",
        "default": "kmh",
        "options": [
          {
            "value": "kmh"
          },
          {
            "value": "mph"
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "result",
        "precision": 4,
        "unit": "",
        "precisionField": "precision",
        "unitField": "__resultUnit",
        "trimTrailingZeros": true,
        "notation": "auto"
      },
      {
        "name": "kmh",
        "precision": 3,
        "unit": "km/h",
        "showWhen": {
          "to": [
            "mph"
          ]
        },
        "notation": "auto"
      },
      {
        "name": "mph",
        "precision": 3,
        "unit": "mph",
        "showWhen": {
          "to": [
            "kmh"
          ]
        },
        "notation": "auto"
      },
      {
        "name": "mps",
        "precision": 3,
        "unit": "m/s",
        "notation": "auto"
      }
    ],
    "interpret": null
  }
}
