Math Utilities

Percentage

Calculate what percentage one value represents of another total. Access via MCP in AI coding assistants or REST API at `/v1/math/percentage`. Pass a value and total to get precise decimal results like `42.857` for 15 out of 35. Eliminates floating-point calculation errors that plague manual percentage computations.

API Endpoint

GET /v1/math/percentage

Code Examples

curl "https://tinyfn.io/v1/math/percentage" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/math/percentage', {
  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/percentage',
    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 calculate what percentage 15 is of 35?

Send value=15 and total=35 to get 42.857142857142854 as the precise percentage result.

What happens if I pass zero as the total value?

Division by zero returns an error since percentages cannot be calculated with a zero denominator.

Can I use this MCP tool with Cursor for percentage calculations in my code?

Yes, the percentage tool works in Cursor and other MCP-compatible editors, perfect for calculating completion rates or success ratios programmatically.

Does this return rounded percentages or full precision?

Returns full floating-point precision without rounding, so you get exact decimal results for further calculations.

How is this different from just doing value/total*100 in code?

Provides consistent, deterministic results across platforms and eliminates potential floating-point precision issues in manual calculations.

Try Percentage Now

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

Get Free API Key