# Mass compare

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

Compare two mixed-unit canonical integer mass amounts using exact nanogram BigInt values.

**Use when you need to: mass compare · compare mass quantities · compare grams and pounds.**

## Supported

- mass compare
- compare mass quantities
- compare grams and pounds

## Not supported

- sort a list of masses
- approximate or rounded compare
- locale unit names
- troy or stone units
- floating-point mass

## Behavior

- left and right are objects with a canonical integer string value and a mass unit.
- Units are exactly ng, ug, mg, g, kg, t, oz, and lb; t is the metric tonne, lb is avoirdupois, oz is 1/16 lb.
- Each amount is converted to nanograms as BigInt; comparison is the numeric order of those nanogram values.
- cmp is the JSON integer -1, 0, or 1 according as left is less than, equal to, or greater than right.
- Negative amounts are allowed; -0 canonicalizes to 0.
- Unknown fields, unknown units, and non-canonical integers are rejected.

## Input

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

## Output

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

## Limits

- max digits: 1000

## Example

Request input:

```json
{
  "left": {
    "value": "1",
    "unit": "lb"
  },
  "right": {
    "value": "16",
    "unit": "oz"
  }
}
```

Response:

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

## How to call it

### MCP

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

```json
{
  "id": "mass-compare",
  "version": "1.0.0",
  "input": {
    "left": {
      "value": "1",
      "unit": "lb"
    },
    "right": {
      "value": "16",
      "unit": "oz"
    }
  }
}
```

### HTTP (no key)

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

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

### CLI

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

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

## Related tools

- [Mass convert](/tools/mass-convert): Convert a canonical integer mass amount between exact nanogram-based units as a reduced rational.
- [Byte size compare](/tools/bytesize-compare): Compare two non-negative integer byte sizes by exact byte amounts.
- [Mass add](/tools/mass-add): Add mixed-unit canonical integer mass amounts and express the sum in a target unit as a reduced rational.
- [Length compare](/tools/length-compare): Compare two integer length measurements by exact nanometer amounts.
- [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.
