Math Utilities

Subtract

Simple arithmetic subtraction that returns a - b with precise decimal handling. Access via MCP in Cursor or Windsurf for AI-powered calculations, or call GET /v1/math/subtract directly. Example: subtract(10, 3) returns 7. Handles floating-point precision issues that can trip up JavaScript's native math operations.

API Endpoint

GET /v1/math/subtract

Code Examples

curl "https://tinyfn.io/v1/math/subtract" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/math/subtract', {
  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/subtract',
    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 do I subtract numbers using TinyFn's subtract tool?

Call the subtract function with two parameters: subtract(a, b) returns a - b. Via REST API: GET /v1/math/subtract?a=10&b=3 returns 7.

Does TinyFn subtract handle floating-point precision correctly?

Yes, it provides accurate decimal arithmetic without JavaScript's floating-point errors like 0.1 - 0.2 = -0.09999999999999998.

Can I use subtract in MCP-enabled AI coding assistants?

Absolutely. Cursor, Windsurf, Claude Code, and other MCP tools can call subtract directly for reliable math in generated code or calculations.

What happens if I subtract a larger number from a smaller one?

It returns the correct negative result. For example, subtract(5, 8) returns -3.

Does subtract work with decimal numbers and scientific notation?

Yes, it handles decimals, negative numbers, and scientific notation inputs like 1e6 or -0.0001 correctly.

Try Subtract Now

Get your free API key and start using Subtract in seconds.

Get Free API Key