# Length compare

`length-compare` · version 1.0.0 · Units & sizes · free, no key needed

Compare two integer length measurements by exact nanometer amounts.

**Use when you need to: length compare · compare length measurements · compare two integer lengths.**

## Supported

- length compare
- compare length measurements
- compare two integer lengths

## Not supported

- sort a list of lengths
- approximate comparison
- nautical miles
- floating-point lengths

## Behavior

- left and right are objects with a canonical integer value and a length unit.
- Units are exactly nm, um, mm, cm, m, km, in, ft, yd, mi using the LENGTH_NM table.
- Each side is converted to nanometers as a BigInt and those amounts are compared.
- cmp is the JSON integer -1, 0, or 1 according as left is less than, equal to, or greater than right.
- Negative values are allowed; input -0 is canonicalized to 0.

## Input

- `left` (object, required)
- `right` (object, required)

## Output

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

## Limits

- max digits: 1000
- units: ["nm","um","mm","cm","m","km","in","ft","yd","mi"]

## Example

Request input:

```json
{
  "left": {
    "value": "1",
    "unit": "m"
  },
  "right": {
    "value": "1",
    "unit": "yd"
  }
}
```

Response:

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

## How to call it

### MCP

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

```json
{
  "id": "length-compare",
  "version": "1.0.0",
  "input": {
    "left": {
      "value": "1",
      "unit": "m"
    },
    "right": {
      "value": "1",
      "unit": "yd"
    }
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/length-compare/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"left":{"value":"1","unit":"m"},"right":{"value":"1","unit":"yd"}}'
```

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

### CLI

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

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

## Related tools

- [Length add](/tools/length-add): Add integer length terms in mixed units and return the exact sum in a chosen unit.
- [Length convert](/tools/length-convert): Convert a canonical integer length between exact SI and international customary units.
- [Byte size compare](/tools/bytesize-compare): Compare two non-negative integer byte sizes by exact byte amounts.
- [Mass compare](/tools/mass-compare): Compare two mixed-unit canonical integer mass amounts using exact nanogram BigInt values.
- [Temperature compare](/tools/temperature-compare): Compare two temperatures in C, F, or K by converting both to Kelvin rationals.
- [Byte size add](/tools/bytesize-add): Add non-negative integer byte-size terms in mixed IEC units and return the exact sum in a chosen unit.
