Math Utilities

Sign

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.

API Endpoint

GET /v1/math/sign

Code Examples

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)

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

What does the sign function return for different numbers?

Returns -1 for any negative number, 0 for zero, and 1 for any positive number. Works with integers, floats, and scientific notation.

How do I use the sign function in my MCP-enabled AI agent?

Call the math/sign tool with your number as input. The agent gets deterministic results instead of potentially incorrect mathematical reasoning about sign determination.

Does the sign function handle edge cases like NaN or infinity?

Yes, it properly handles IEEE 754 special values: NaN returns NaN, positive infinity returns 1, negative infinity returns -1.

What's the difference between this and just checking if a number is positive or negative?

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.

Can I use this for implementing custom mathematical functions?

Absolutely. Common uses include implementing absolute value derivatives, step functions, or any algorithm requiring sign-based branching with guaranteed accuracy.

Try Sign Now

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

Get Free API Key