modulo
Calculate the remainder of a divided by b. Returns an error if b is zero.
Instructions
Remainder of a / b. Errors on zero divisor.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | ||
| b | Yes |
Implementation Reference
- cruncher.js:1711-1711 (handler)The 'modulo' tool handler in the toolHandlers object. Delegates to safeMath.modulo(a, b).
modulo: ({ a, b }) => safeMath.modulo(a, b), - cruncher.js:1277-1288 (helper)The safeMath.modulo helper function implementing the modulo logic with safe floating-point arithmetic via integer-scaling.
modulo: (a, b) => { if (b === 0) throw new Error("Modulo by zero is not allowed."); const d1 = countDecimals(a); const d2 = countDecimals(b); const maxDecimals = Math.max(d1, d2); const multiplier = Math.pow(10, maxDecimals); return ( (Math.round(a * multiplier) % Math.round(b * multiplier)) / multiplier ); }, }; - cruncher.js:857-874 (schema)The 'modulo' tool definition in the master tools list, including inputSchema (a: number, b: number), description, and annotations.
// --- Additional Math Functions --- { name: "modulo", annotations: { title: "Modulo", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, description: "Remainder of a / b. Errors on zero divisor.", inputSchema: { type: "object", properties: { a: { type: "number" }, b: { type: "number" } }, required: ["a", "b"], }, }, - cruncher.js:69-73 (registration)The 'modulo' tool is registered in the 'standard' tier of the TOOL_TIERS configuration.
standard: [ "evaluate_expression", "add", "subtract", "multiply", "divide", "sqrt", "power", "absolute", "modulo", "factorial", "logarithm", "natural_log", "get_constant",