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.
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)
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"
}
}
}
}
Use the TinyFn absolute value tool directly in your MCP-enabled editor. Pass any number and get the positive equivalent instantly.
Absolute value handles all numeric formats correctly including scientific notation and edge cases like -0, while string manipulation can break with complex number formats.
Yes, it handles integers, decimals, and scientific notation. Input -3.14159 returns 3.14159, input -1.5e-10 returns 1.5e-10.
Zero returns zero. Both positive zero and negative zero (if your system distinguishes them) will return positive zero.
Perfect use case. Agents can compute |x2-x1| and |y2-y1| for Manhattan distance, or as components in Euclidean distance formulas.
Get your free API key and start using Absolute Value in seconds.
Get Free API Key