{
  "schemaVersion": 1,
  "slug": "improper-fraction-calculator",
  "category": "math",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "f18ebc6c01dedc592e8e35b7523684c8e50e40944fb756b137fe2ffba81e31f4",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/improper-fraction-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": "a = trunc(n ÷ d) ; r = |n − a × d| ; n ÷ d = a + r ÷ |d|",
    "vars": [
      [
        "n",
        "numerator"
      ],
      [
        "d",
        "denominator"
      ],
      [
        "a",
        "whole-number part"
      ],
      [
        "r",
        "remainder"
      ]
    ],
    "note": "The sign applies to the whole mixed number; values with magnitude below one display as a signed proper fraction."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "if(!Number.isInteger(numerator)||!Number.isInteger(denominator)||denominator===0)return{whole:null,remainder:null,mixedNumber:null,decimal:null,__error:'inputError'}; const sign=numerator*denominator<0?'-':''; const absN=Math.abs(numerator), absD=Math.abs(denominator); const whole=Math.trunc(numerator/denominator); const rem=absN%absD; const mixedNumber=rem===0?String(whole):(absN<absD?sign+rem+'/'+absD:sign+Math.floor(absN/absD)+' '+rem+'/'+absD); return {whole,remainder:rem,mixedNumber,decimal:numerator/denominator};",
    "inputs": [
      {
        "name": "numerator",
        "type": "number",
        "default": 17,
        "min": -10000000,
        "max": 10000000,
        "step": 1,
        "requiredValue": true
      },
      {
        "name": "denominator",
        "type": "number",
        "default": 5,
        "min": -10000000,
        "max": 10000000,
        "step": 1,
        "requiredValue": true
      }
    ],
    "outputs": [
      {
        "name": "mixedNumber",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "whole",
        "precision": 0,
        "unit": "",
        "trimTrailingZeros": true
      },
      {
        "name": "remainder",
        "precision": 0,
        "unit": "",
        "trimTrailingZeros": true
      },
      {
        "name": "decimal",
        "precision": 6,
        "unit": "",
        "trimTrailingZeros": true
      }
    ],
    "interpret": null
  }
}
