# Integer compare

`integer-compare` · version 1.0.0 · Numbers & math · free, no key needed

Compare two canonical signed base-10 integer strings using BigInt.

**Use when you need to: integer compare · compare integers · cmp integer strings.**

## Supported

- integer compare
- compare integers
- cmp integer strings

## Not supported

- floats
- locale numeric
- Number coercion

## Behavior

- Inputs are canonical signed base-10 integer strings matching /^-?(0|[1-9][0-9]*)$/.
- Leading zeros, plus signs, spaces, decimals, exponents, hex, empty strings, and -0 are rejected.
- At most 256 digits excluding the sign. Computation uses BigInt. JSON BigInt is never returned.
- Canonical form is unchanged; 0 is "0".
- result is -1 if a<b, 0 if equal, and 1 if a>b. result is a JSON integer, not BigInt.

## Input

- `a` (string, required): min length 1; max length 257
- `b` (string, required): min length 1; max length 257

## Output

- `result` (one of -1, 0, 1, required)

## Limits

- max integer digits: 256

## Example

Request input:

```json
{
  "a": "-2",
  "b": "10"
}
```

Response:

```json
{
  "result": {
    "result": -1
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "integer-compare",
  "version": "1.0.0",
  "input": {
    "a": "-2",
    "b": "10"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/integer-compare/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"a":"-2","b":"10"}'
```

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

### CLI

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

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

## Related tools

- [Array integer mode](/tools/array-integer-mode): Return the most frequent canonical integers, listing every mode in first-seen order.
- [Decimal compare](/tools/decimal-compare): Compare two decimal strings exactly after canonicalization.
- [Integer add](/tools/integer-add): Add two canonical signed integer strings and return their canonical sum.
- [Integer sort](/tools/integer-sort): Stable-sort canonical signed base-10 integer strings using BigInt.
- [Array integer cumulative sum](/tools/array-integer-cumulative-sum): Replace an array of canonical integer strings with equal-length prefix sums.
- [Array integer GCD](/tools/array-integer-gcd): Compute the non-negative greatest common divisor of an array of canonical integer strings.
