Calc Exact
calc_exactPerform exact arithmetic with rationals and arbitrary precision to avoid floating-point errors. Ideal for verifying thresholds, ratios, and comparisons like 0.1+0.2 == 0.3.
Instructions
Use calc_exact, not evaluate_expression, for a literal arithmetic expression with no symbols in it. EXACT arithmetic: 0.1 + 0.2 == 0.3 is True here (False in plain Python).
Everything is an exact rational, integers are arbitrary precision. Supports
/ // % ** comparisons, bitwise ops (& | ^ << >> ~) on integers, and whitelisted math functions (sqrt, log, sin, ...) plus pi/e/tau. Use BEFORE asserting any computed number: thresholds, ratios, overflows, 'X is N% of Y'. Examples: '2**64 - 1', 'comb(52,5)', '0.1+0.2 == 0.3', '0xff & 0x0f'.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"expr": "<expr>"
},
"name": "calc_exact"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expr | Yes | Literal arithmetic expression with no symbols, e.g. '2**64 - 1', 'comb(52,5)', '0.1+0.2 == 0.3' |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||