# Byte size compare

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

Compare two non-negative integer byte sizes by exact byte amounts.

**Use when you need to: bytesize compare · compare binary byte sizes · compare kibibytes and mebibytes.**

## Supported

- bytesize compare
- compare binary byte sizes
- compare kibibytes and mebibytes

## Not supported

- SI kB/MB/GB
- bits
- signed byte sizes
- sort a list of sizes
- approximate comparison

## Behavior

- left and right are objects with a non-negative canonical integer value and a byte-size unit.
- Units are exactly B, KiB, MiB, GiB, TiB using the BYTE_SIZE table (powers of 1024).
- Each side is converted to bytes 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.
- Input -0 is canonicalized to 0; other negatives, SI decimal prefixes, and bit units are rejected.

## Input

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

## Output

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

## Limits

- max digits: 1000
- units: ["B","KiB","MiB","GiB","TiB"]

## Example

Request input:

```json
{
  "left": {
    "value": "1",
    "unit": "KiB"
  },
  "right": {
    "value": "1024",
    "unit": "B"
  }
}
```

Response:

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

## How to call it

### MCP

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

```json
{
  "id": "bytesize-compare",
  "version": "1.0.0",
  "input": {
    "left": {
      "value": "1",
      "unit": "KiB"
    },
    "right": {
      "value": "1024",
      "unit": "B"
    }
  }
}
```

### HTTP (no key)

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

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

### CLI

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

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

## Related tools

- [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.
- [Byte size convert](/tools/bytesize-convert): Convert a non-negative integer byte size between IEC binary units as an exact rational.
- [Mass compare](/tools/mass-compare): Compare two mixed-unit canonical integer mass amounts using exact nanogram BigInt values.
- [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.
- [Length add](/tools/length-add): Add integer length terms in mixed units and return the exact sum in a chosen unit.
