subtract
Subtract two numbers by providing numeric values for a and b. Returns the difference.
Instructions
Subtracts two numbers.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | ||
| b | Yes |
Implementation Reference
- cruncher.js:1326-1333 (handler)The tool handler function that executes the 'subtract' tool. It destructures arguments {a, b} and delegates to safeMath.subtract(a, b).
/** * Subtracts the second number from the first. * @param {Object} args - The arguments object. * @param {number} args.a - The first number. * @param {number} args.b - The second number to subtract. * @returns {number} The difference of a and b. */ subtract: ({ a, b }) => safeMath.subtract(a, b), - cruncher.js:1249-1258 (helper)The safeMath.subtract helper that performs safe floating-point subtraction using integer scaling to avoid precision errors.
subtract: (a, b) => { 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:246-261 (schema)The input schema and tool definition for the 'subtract' tool, specifying name, description, annotations, and inputSchema (type object with required properties a and b, both numbers).
{ name: "subtract", annotations: { title: "Subtract", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, description: "Subtracts two numbers.", inputSchema: { type: "object", properties: { a: { type: "number" }, b: { type: "number" } }, required: ["a", "b"], }, - cruncher.js:86-90 (registration)The filterToolsByTier function that registers/enables the 'subtract' tool based on the active CRUNCHER_TOOL_SET (minimal, standard, or full). 'subtract' appears in both minimal and standard tiers.
function filterToolsByTier(allTools, tier) { if (tier === "full") return allTools; const allowed = new Set(TOOL_TIERS[tier]); return allTools.filter(t => allowed.has(t.name)); }