Number Utilities

Count Digits

Counts digits in any number, handling integers, decimals, and scientific notation. Access via MCP in Cursor or Windsurf, or REST at GET /v1/number/count-digits. Returns precise digit counts — useful for validation, formatting, or mathematical analysis. Distinguishes between total digits and digits before/after decimal points.

API Endpoint

GET /v1/number/count-digits

Code Examples

curl "https://tinyfn.io/v1/number/count-digits" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/number/count-digits', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/number/count-digits',
    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 number tools:

{
  "mcpServers": {
    "tinyfn-number": {
      "url": "https://tinyfn.io/mcp/number",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How does count digits handle decimal numbers?

Counts all numeric digits, excluding the decimal point itself. For example, 123.456 returns 6 total digits (3 before decimal, 3 after).

Does it work with scientific notation like 1.23e+10?

Yes, it processes the coefficient digits only. 1.23e+10 counts as 3 digits from the 1.23 portion, ignoring the exponent formatting.

Can I use this MCP tool to validate input length in Claude Code?

Absolutely. AI agents can call count-digits to verify numeric inputs meet length requirements before processing, ensuring data validation consistency.

What happens with negative numbers or leading zeros?

Negative signs are ignored, only digits count. Leading zeros in decimals (like 0.123) are included, so 0.123 has 4 digits total.

Does count digits work differently than string length for numbers?

Yes, it's number-aware. String length on '123.45' returns 6 (including the dot), while count-digits returns 5 (digits only).

Try Count Digits Now

Get your free API key and start using Count Digits in seconds.

Get Free API Key