Computes modulo operation (a mod b) returning the remainder when dividing two numbers. Access via MCP in Cursor or Windsurf for AI-powered calculations, or call GET /v1/math/modulo directly. Essential for cyclic algorithms, hash functions, and range wrapping. Handles negative numbers using mathematical modulo definition, not programming remainder.
curl "https://tinyfn.io/v1/math/modulo" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/math/modulo', {
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/modulo',
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"
}
}
}
}
Modulo uses mathematical definition where result has same sign as divisor, while remainder (like % in many languages) can be negative. For positive numbers, they're identical.
Call the modulo tool with dividend and divisor parameters. The AI agent gets exact computation instead of potentially incorrect mental math.
Division by zero returns an error. Negative divisors work correctly using mathematical modulo definition, ensuring positive results.
Yes, perfect for circular arrays, angle normalization, and hash table indexing. Use (index + offset) mod array_length for safe wrapping.
Accepts integers and floating-point numbers. Returns precise decimal results for non-integer inputs, maintaining full mathematical accuracy.