{
  "schemaVersion": 1,
  "slug": "modulo-calculator",
  "category": "math",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "2cbc9141d0855e5bf3265cc46e1a52ed3100bee48b737ac89874184c23fcd13d",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/modulo-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": "q = trunc(a ÷ b); r = a − qb; r_E = ((a mod b) + |b|) mod |b|",
    "vars": [
      [
        "q",
        "truncated quotient"
      ],
      [
        "r",
        "remainder (sign of a)"
      ],
      [
        "r_E",
        "non-negative Euclidean remainder"
      ],
      [
        "a",
        "dividend"
      ],
      [
        "b",
        "divisor"
      ]
    ],
    "note": "Inputs must be integers and the divisor must be nonzero. The truncating remainder can be negative; Euclidean modulo is normalized to a non-negative result."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "if(!Number.isInteger(a)||!Number.isInteger(b)||b===0)return{remainder:null,quotient:null,euclideanMod:null,divisible:'—',__error:'inputError'};const q=Math.trunc(a/b),r=a-q*b,em=((a%b)+Math.abs(b))%Math.abs(b);return{remainder:r,quotient:q,euclideanMod:em,divisible:r===0?'Yes':'No'}",
    "inputs": [
      {
        "name": "a",
        "type": "number",
        "default": 27,
        "min": -1000000000000,
        "max": 1000000000000,
        "step": 1
      },
      {
        "name": "b",
        "type": "number",
        "default": 5,
        "min": -1000000000000,
        "max": 1000000000000,
        "step": 1
      }
    ],
    "outputs": [
      {
        "name": "remainder",
        "precision": 4,
        "unit": ""
      },
      {
        "name": "quotient",
        "precision": 4,
        "unit": ""
      },
      {
        "name": "euclideanMod",
        "precision": 4,
        "unit": ""
      },
      {
        "name": "divisible",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
