Skip to main content
Glama

calc_exact

Perform exact arithmetic to prevent floating-point precision errors. Compute rational numbers, arbitrary-precision integers, bitwise operations, and math functions for assertions and comparisons.

Instructions

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'.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exprYes
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that all numbers are exact rationals, integers are arbitrary precision, and lists supported operations and math functions. It also notes the difference from plain Python, which is key behavioral context. However, it doesn't mention error handling or edge cases like division by zero, but the core behavior is well covered.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured. It starts with a clear statement of the tool's purpose, then explains the underlying model, lists supported operations, and provides usage guidance and examples. Every sentence adds value, and the examples are illustrative without being verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (supports many operations and functions) and the lack of annotations or output schema, the description is quite complete. It covers the main behavioral aspects, usage context, and examples. However, it could be more complete by mentioning potential error conditions or the format of the result (e.g., returns a string or number), but overall it provides sufficient information for an agent to use the tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has only one parameter 'expr' with no description, and schema description coverage is 0%. The description compensates by explaining what the expression should contain, providing examples, and listing supported operations. This gives the agent a clear understanding of how to construct the expression string, though it doesn't specify syntax details like operator precedence or function call format.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool performs exact arithmetic with rational numbers, distinguishing it from plain Python float arithmetic. It explicitly lists supported operations and gives examples, making the purpose unambiguous and distinct from siblings like calc_stats or evaluate_expression.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly says to use this tool BEFORE asserting any computed number, and provides specific use cases (thresholds, ratios, overflows, percentages). It contrasts with plain Python behavior, giving clear guidance on when this tool is appropriate over alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/The-40-Thieves/codecalc'

If you have feedback or need assistance with the MCP directory API, please join our Discord server