Math Utilities

Is Integer

Validates whether a given number is an integer with perfect accuracy. Use via MCP in Cursor or Windsurf, or call GET /v1/math/is-integer directly. Returns true for whole numbers like 42 or -7, false for decimals like 3.14. Essential for data validation in AI agents handling numeric input.

API Endpoint

GET /v1/math/is-integer

Code Examples

curl "https://tinyfn.io/v1/math/is-integer" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/math/is-integer', {
  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/is-integer',
    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 does is-integer handle edge cases like NaN and infinity?

Returns false for NaN, positive infinity, and negative infinity since these are not valid integers.

Does is-integer return true for numbers like 5.0?

Yes, 5.0 is mathematically an integer despite decimal notation. The tool checks mathematical properties, not string format.

Can MCP agents use is-integer for input validation?

Absolutely. Claude Code and other MCP clients can validate user input before processing, preventing errors in calculations.

What's the difference between is-integer and checking if number % 1 === 0?

TinyFn's implementation handles edge cases like infinity and NaN correctly, while modulo checks can produce unexpected results.

Does is-integer work with very large numbers?

Yes, it correctly identifies integers within JavaScript's safe integer range and handles precision issues automatically.

Try Is Integer Now

Get your free API key and start using Is Integer in seconds.

Get Free API Key