Math Utilities

Compare Decimals

Compare decimal numbers with mathematically correct results and detailed explanations. Access via MCP in Cursor or Windsurf, or call GET /v1/math/compare-decimals directly. Handles tricky cases like 0.9 vs 0.11 (returns "greater than") that confuse string-based comparisons. Returns comparison result, numerical difference, and step-by-step reasoning.

API Endpoint

GET /v1/math/compare-decimals

Code Examples

curl "https://tinyfn.io/v1/math/compare-decimals" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/math/compare-decimals', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/math/compare-decimals',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's math tools:

{
  "mcpServers": {
    "tinyfn-math": {
      "url": "https://tinyfn.io/mcp/math",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How does decimal comparison handle floating point precision issues?

The tool uses precise decimal arithmetic to avoid floating point errors. It correctly compares values like 0.1 + 0.2 vs 0.3 without precision loss that plagues standard programming comparisons.

What output format does the compare decimals API return?

Returns JSON with comparison result ("greater", "less", "equal"), numerical difference, and detailed explanation of the comparison logic used.

Can I compare negative decimals and scientific notation?

Yes, handles negative numbers (-0.5 vs -0.25) and scientific notation (1.5e-3 vs 0.0015). All standard decimal formats are supported including very large and very small numbers.

How do I use decimal comparison in my MCP-enabled AI coding assistant?

Simply ask your AI agent to compare two decimal values. The MCP tool provides accurate results with explanations, perfect for financial calculations or data validation workflows.

Why not just use programming language comparison operators?

Language operators can fail with floating point precision issues and don't provide explanations. This tool ensures mathematical accuracy and gives detailed reasoning for the comparison result.

Try Compare Decimals Now

Get your free API key and start using Compare Decimals in seconds.

Get Free API Key