Math Utilities

Absolute Value

Returns the absolute value of any number, converting negative values to positive while keeping positive values unchanged. Call via MCP in Cursor or Windsurf, or hit the REST endpoint `/v1/math/abs`. Essential for distance calculations, error handling, and data normalization. Works with integers, decimals, and scientific notation.

API Endpoint

GET /v1/math/abs

Code Examples

curl "https://tinyfn.io/v1/math/abs" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/math/abs', {
  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/abs',
    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 get absolute value using MCP in Cursor?

Use the TinyFn absolute value tool directly in your MCP-enabled editor. Pass any number and get the positive equivalent instantly.

What's the difference between absolute value and just removing the negative sign?

Absolute value handles all numeric formats correctly including scientific notation and edge cases like -0, while string manipulation can break with complex number formats.

Does the absolute value function work with decimal numbers?

Yes, it handles integers, decimals, and scientific notation. Input -3.14159 returns 3.14159, input -1.5e-10 returns 1.5e-10.

What happens if I pass zero to the absolute value function?

Zero returns zero. Both positive zero and negative zero (if your system distinguishes them) will return positive zero.

Can AI agents use this for calculating distances between coordinates?

Perfect use case. Agents can compute |x2-x1| and |y2-y1| for Manhattan distance, or as components in Euclidean distance formulas.

Try Absolute Value Now

Get your free API key and start using Absolute Value in seconds.

Get Free API Key