{
  "schemaVersion": 1,
  "slug": "temperature-calculator",
  "category": "conversion",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "efeb23566484ca92e4c193dc96e2b69b11e95ecceda4d4c97d8b8eccc14a2152",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/temperature-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": "°F = °C × 9÷5 + 32; K = °C + 273.15",
    "vars": [
      [
        "°C",
        "Temperature in Celsius"
      ],
      [
        "°F",
        "Temperature in Fahrenheit"
      ],
      [
        "K",
        "Temperature in kelvin"
      ]
    ],
    "note": "Input is first converted to Celsius: (°F − 32) × 5÷9, or K − 273.15. Rankine = K × 9÷5."
  },
  "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 via kelvin with the scale and offset of the selected temperature unit.",
    "limitations": "Absolute temperatures below 0 K are rejected. These are temperatures, not temperature differences.",
    "implementationHash": "efeb23566484ca92e4c193dc96e2b69b11e95ecceda4d4c97d8b8eccc14a2152",
    "domain": "conversion"
  },
  "contract": {
    "compute": "const T={\"c\":{\"scale\":1,\"offset\":273.15},\"f\":{\"scale\":0.5555555555555556,\"offset\":255.3722222222222},\"k\":{\"scale\":1,\"offset\":0},\"r\":{\"scale\":0.5555555555555556,\"offset\":0}}, U={\"c\":\"°C\",\"f\":\"°F\",\"k\":\"K\",\"r\":\"°R\"}, L={};const pair=[from,to],source=pair[0],target=pair[1]; if(!Number.isFinite(value)||value<-1000||value>10000||!Object.prototype.hasOwnProperty.call(T,source)||!Object.prototype.hasOwnProperty.call(T,target))return {\"result\":null,\"celsius\":null,\"fahrenheit\":null,\"kelvin\":null,\"rankine\":null,\"__error\":\"inputError\"};let kelvin=value*T[source].scale+T[source].offset; if(kelvin < -1e-9)return {\"result\":null,\"celsius\":null,\"fahrenheit\":null,\"kelvin\":null,\"rankine\":null,\"__error\":\"invalidTemperature\"};if(kelvin<0)kelvin=0; const celsius=kelvin-273.15, out=(function(value,from){const c = from === 'c' ? value : from === 'f' ? (value-32)*5/9 : value-273.15; if (c < -273.15) return { __error: 'invalidTemperature', celsius: null, fahrenheit: null, kelvin: null, rankine: null }; return { celsius: c, fahrenheit: c*9/5+32, kelvin: c+273.15, rankine: (c+273.15)*9/5 };})(celsius,'c'); if(out.__error)return {...{\"result\":null,\"celsius\":null,\"fahrenheit\":null,\"kelvin\":null,\"rankine\":null},...out};out.result=(kelvin-T[target].offset)/T[target].scale;out.__resultUnit=U[target];return out;",
    "inputs": [
      {
        "name": "value",
        "type": "number",
        "default": 25,
        "min": -1000,
        "max": 10000,
        "step": 0.1,
        "requiredValue": true,
        "strictRange": true,
        "unitField": "from",
        "minByUnit": {
          "c": -273.15,
          "f": -459.67,
          "k": 0,
          "r": 0
        },
        "unitLabels": {
          "c": "°C",
          "f": "°F",
          "k": "K",
          "r": "°R"
        }
      },
      {
        "name": "from",
        "type": "select",
        "default": "c",
        "options": [
          {
            "value": "c"
          },
          {
            "value": "f"
          },
          {
            "value": "k"
          },
          {
            "value": "r"
          }
        ]
      },
      {
        "name": "precision",
        "type": "select",
        "default": 4,
        "options": [
          {
            "value": 0
          },
          {
            "value": 2
          },
          {
            "value": 4
          },
          {
            "value": 6
          }
        ]
      },
      {
        "name": "to",
        "type": "select",
        "default": "f",
        "options": [
          {
            "value": "f"
          },
          {
            "value": "c"
          },
          {
            "value": "k"
          },
          {
            "value": "r"
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "result",
        "precision": 4,
        "precisionField": "precision",
        "unitField": "__resultUnit",
        "trimTrailingZeros": true,
        "notation": "auto"
      },
      {
        "name": "celsius",
        "precision": 2,
        "unit": "°C",
        "showWhen": {
          "to": [
            "f",
            "k",
            "r"
          ]
        },
        "notation": "auto"
      },
      {
        "name": "fahrenheit",
        "precision": 2,
        "unit": "°F",
        "showWhen": {
          "to": [
            "c",
            "k",
            "r"
          ]
        },
        "notation": "auto"
      },
      {
        "name": "kelvin",
        "precision": 2,
        "unit": "K",
        "showWhen": {
          "to": [
            "c",
            "f",
            "r"
          ]
        },
        "notation": "auto"
      },
      {
        "name": "rankine",
        "precision": 2,
        "unit": "°R",
        "showWhen": {
          "to": [
            "c",
            "f",
            "k"
          ]
        },
        "notation": "auto"
      }
    ],
    "interpret": null
  }
}
