{
  "schemaVersion": 1,
  "slug": "weight-calculator",
  "category": "conversion",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "77463728fc834483945786cfb23fdebbb45ee699b74cd3704578e1c1a822ec19",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/weight-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": "kg = value × F[from]; result = kg ÷ F[to]",
    "vars": [
      [
        "value",
        "Amount to convert"
      ],
      [
        "from",
        "Original unit"
      ],
      [
        "to",
        "Target unit"
      ],
      [
        "F",
        "Factor in kilograms"
      ]
    ],
    "note": "F in kg: mg 1e-6, g 0.001, kg 1, tonne 1000, oz 0.028349523125, lb 0.45359237, stone 6.35029318, US ton 907.18474."
  },
  "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 mass via kilograms; US ton and metric tonne are distinct options.",
    "limitations": "Only the displayed unit definitions are converted; rounding and measurement uncertainty are separate.",
    "implementationHash": "77463728fc834483945786cfb23fdebbb45ee699b74cd3704578e1c1a822ec19",
    "domain": "conversion"
  },
  "contract": {
    "compute": "const units={\"mg\":\"mg\",\"g\":\"g\",\"kg\":\"kg\",\"t\":\"t\",\"oz\":\"oz\",\"lb\":\"lb\",\"st\":\"st\",\"ton\":\"US ton\"}, factors={\"mg\":0.000001,\"g\":0.001,\"kg\":1,\"t\":1000,\"oz\":0.028349523125,\"lb\":0.45359237,\"st\":6.35029318,\"ton\":907.18474}; if(!Number.isFinite(value)||value<-1000000000000||value>1000000000000||!Object.prototype.hasOwnProperty.call(units,from)||!Object.prototype.hasOwnProperty.call(units,to))return {\"result\":null,\"inGrams\":null,\"inKg\":null,\"__error\":\"inputError\"}; const out=(function(){const F={mg:1e-6,g:0.001,kg:1,t:1000,oz:0.028349523125,lb:0.45359237,st:6.35029318,ton:907.18474}; const kg=value*F[from]; return { result: kg/F[to], inGrams: kg*1000, inKg: kg };})(); if(out.__error)return {...{\"result\":null,\"inGrams\":null,\"inKg\":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": "kg",
        "options": [
          {
            "value": "kg"
          },
          {
            "value": "mg"
          },
          {
            "value": "g"
          },
          {
            "value": "t"
          },
          {
            "value": "oz"
          },
          {
            "value": "lb"
          },
          {
            "value": "st"
          },
          {
            "value": "ton"
          }
        ]
      },
      {
        "name": "to",
        "type": "select",
        "default": "lb",
        "options": [
          {
            "value": "lb"
          },
          {
            "value": "mg"
          },
          {
            "value": "g"
          },
          {
            "value": "kg"
          },
          {
            "value": "t"
          },
          {
            "value": "oz"
          },
          {
            "value": "st"
          },
          {
            "value": "ton"
          }
        ]
      },
      {
        "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": "inGrams",
        "precision": 4,
        "unit": "g",
        "showWhen": {
          "to": [
            "mg",
            "kg",
            "t",
            "oz",
            "lb",
            "st",
            "ton"
          ]
        },
        "notation": "auto"
      },
      {
        "name": "inKg",
        "precision": 6,
        "unit": "kg",
        "showWhen": {
          "to": [
            "mg",
            "g",
            "t",
            "oz",
            "lb",
            "st",
            "ton"
          ]
        },
        "notation": "auto"
      }
    ],
    "interpret": null
  }
}
