Returns the mathematical sign of any number: -1 for negatives, 0 for zero, and 1 for positives. Access via MCP in Cursor or Windsurf, or call GET /v1/math/sign with your number. Perfect for AI agents doing mathematical analysis, implementing signum functions, or normalizing directional calculations without floating-point quirks.
curl "https://tinyfn.io/v1/math/sign" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/math/sign', {
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/sign',
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"
}
}
}
}
Returns -1 for any negative number, 0 for zero, and 1 for any positive number. Works with integers, floats, and scientific notation.
Call the math/sign tool with your number as input. The agent gets deterministic results instead of potentially incorrect mathematical reasoning about sign determination.
Yes, it properly handles IEEE 754 special values: NaN returns NaN, positive infinity returns 1, negative infinity returns -1.
The sign function provides the standard mathematical signum result as a single numeric value, useful for algorithms that multiply by sign or need normalized direction indicators.
Absolutely. Common uses include implementing absolute value derivatives, step functions, or any algorithm requiring sign-based branching with guaranteed accuracy.