{
  "schemaVersion": 1,
  "slug": "discount-calculator",
  "category": "finance",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "5c3af7cbc254b0c15fa0ae5cfbd0e61b02cce0b1d95bda00c61a9fc54360f0e9",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/discount-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 = P × (1 − d ÷ 100); S = P × d ÷ 100",
    "vars": [
      [
        "P",
        "original price"
      ],
      [
        "d",
        "discount percentage"
      ],
      [
        "F",
        "final price"
      ],
      [
        "S",
        "savings"
      ]
    ],
    "note": "d is a percent; F and S always add up to P."
  },
  "externalEvidence": {
    "reviewedAt": "2026-10-27",
    "sources": [
      {
        "name": "OpenStax — Percent and weighted arithmetic",
        "url": "https://openstax.org/books/prealgebra-2e/pages/6-1-understand-percent"
      },
      {
        "name": "NIST / SEMATECH e-Handbook — Percentages",
        "url": "https://www.itl.nist.gov/div898/handbook/mpc/section5/mpc55.htm"
      }
    ],
    "referenceRole": "definition",
    "implementationHash": "5c3af7cbc254b0c15fa0ae5cfbd0e61b02cce0b1d95bda00c61a9fc54360f0e9",
    "basis": "finalPrice = price × (1 − discount/100); savings = price × discount/100. Discount is treated as a single-step percent off the listed price.",
    "limitations": "Does not stack successive discounts, apply tax, or round to currency subunits. A discount above 100% can produce a negative final price with the current formula; treat that as out-of-scope for ordinary sale math."
  },
  "contract": {
    "compute": "return { finalPrice: price*(1-discount/100), savings: price*discount/100 };",
    "inputs": [
      {
        "name": "price",
        "type": "number",
        "default": 100,
        "min": 0,
        "max": 100000000,
        "step": 1
      },
      {
        "name": "discount",
        "type": "number",
        "default": 25,
        "min": 0,
        "max": 100,
        "step": 0.5,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "finalPrice",
        "precision": 2,
        "unit": "USD"
      },
      {
        "name": "savings",
        "precision": 2,
        "unit": "USD"
      }
    ],
    "interpret": null
  }
}
