# Xpath10 number

`xpath10-number` · version 1.0.0 · Structured formats · free, no key needed

Evaluate an XPath 1.0 numeric expression: arithmetic, div, mod, floor, ceiling, round, and number conversion.

**Use when you need to: xpath 1.0 number result · xpath div mod addition and multiplication · xpath floor ceiling and round.**

## Decide before calling

Read the [versioned contract](/v1/tools/xpath10-number/versions/1.0.0) and the supported scope below. Reuse `xpath10-number@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `xpath10-number@1.0.0` for xpath 1.0 number result. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- xpath 1.0 number result
- xpath div mod addition and multiplication
- xpath floor ceiling and round
- xpath number function and string-length
- compute an xpath 1.0 numeric expression
- xpath arithmetic keeping negative zero
- xpath ieee 754 division and remainder
- מספר xpath number

## Not supported

- sum a node-set with sum()
- exact decimal or integer arithmetic beyond IEEE 754 binary64
- XPath 2.0 integer division idiv

## Behavior

- Returns an XPath 1.0 number. result is the exact token, including -0 for negative zero. xpath_string is the section 4.2 string, which is 0 for negative zero. A string or boolean result is unsupported_input reason result_type.
- div is IEEE 754 division. Division by zero returns Infinity, -Infinity, or NaN and is not an error. mod is the truncating remainder with the sign of the dividend, the same rule as ECMAScript %. / is a location path and is rejected.
- Unary minus is the only unary operator. +1 is a syntax error. 5 mod -2 is 5 mod (-2). Keyword div and mod match only token kind name.
- round halves toward positive infinity. round of a number that is less than zero and greater than or equal to -0.5 is negative zero. floor and ceiling follow section 4.4.
- number() accepts optional XML whitespace, an optional minus, and an XPath Number. A leading plus, an exponent, or any other text is NaN. Integers are plain decimal with no exponent.
- Check order: UTF-8 input bytes, parse limits, the 96-character cap on any string the expression builds, the result type, then the JSON byte cap. Key order is result then xpath_string.
- A 23-digit exact integer such as 10^22 fills the 77-byte output cap. A longer exact decimal such as 2^200 is limit_exceeded on output bytes, not a rounded rewrite.

## Input

- `expression` (string, required): min length 1; max length 512; XPath 1.0 value expression. maxLength counts Unicode code points. The UTF-8 cap is limits.max_input_bytes.

## Output

- `result` (string, required): min length 1; max length 96; Exact numeric token. Negative zero is -0. NaN, Infinity, and -Infinity are those words.
- `xpath_string` (string, required): min length 1; max length 96; Section 4.2 string value of the number. Negative zero is 0.

## Limits

- max input bytes: 512
- max string codepoints: 96
- max depth: 8
- max nodes: 21
- max arguments: 4
- max output bytes: 77

## Example

Request input:

```json
{
  "expression": "5 mod 2"
}
```

Response:

```json
{
  "result": {
    "result": "1",
    "xpath_string": "1"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "xpath10-number",
  "version": "1.0.0",
  "input": {
    "expression": "5 mod 2"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/xpath10-number/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"expression":"5 mod 2"}'
```

The machine-readable contract is at [/v1/tools/xpath10-number/versions/1.0.0](/v1/tools/xpath10-number/versions/1.0.0).

### CLI

```sh
node cli.mjs run xpath10-number 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Xpath10 boolean](/tools/xpath10-boolean): Evaluate an XPath 1.0 boolean expression: comparisons, and, or, not, starts-with, contains, and boolean conversion.
- [Xpath10 evaluate](/tools/xpath10-evaluate): Evaluate an XPath 1.0 value expression and return its type with an exact string, number, or boolean token.
- [Xpath10 string](/tools/xpath10-string): Evaluate an XPath 1.0 expression that yields a string, including concat, substring, translate, and string conversion.
- [Xpath10 count](/tools/xpath10-count): Count the nodes in an XPath 1.0 node-set from location paths, axes, predicates, namespaces and union.
- [Xpath10 select](/tools/xpath10-select): Select an XPath 1.0 node-set from location paths, axes, predicates, namespaces and union, in document order.
- [Xpath10 paths](/tools/xpath10-paths): List the canonical XPath 1.0 path of each node in a location-path node-set, in document order.
