# Byte size add

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

Add non-negative integer byte-size terms in mixed IEC units and return the exact sum in a chosen unit.

**Use when you need to: bytesize add · add binary byte sizes · sum kibibyte amounts.**

## Supported

- bytesize add
- add binary byte sizes
- sum kibibyte amounts

## Not supported

- SI kB/MB/GB
- bits
- signed byte sizes
- more than 32 terms
- subtract byte sizes

## Behavior

- terms is an array of 1 to 32 objects, each 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 term is converted to bytes as a BigInt and those amounts are summed.
- If the byte sum exceeds 1000 digits, the call is rejected.
- The byte sum is converted to the to unit as a reduced canonical rational.
- Input -0 is canonicalized to 0; other negatives, SI decimal prefixes, and bit units are rejected.

## Input

- `terms` (array of object, required): min items 1; max items 32
- `to` (one of "B", "KiB", "MiB", "GiB", "TiB", required)

## Output

- `numerator` (string, required): pattern `^(0|[1-9][0-9]*)$`
- `denominator` (string, required): pattern `^[1-9][0-9]*$`

## Limits

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

## Example

Request input:

```json
{
  "terms": [
    {
      "value": "1",
      "unit": "KiB"
    },
    {
      "value": "512",
      "unit": "B"
    }
  ],
  "to": "B"
}
```

Response:

```json
{
  "result": {
    "numerator": "1536",
    "denominator": "1"
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "bytesize-add",
  "version": "1.0.0",
  "input": {
    "terms": [
      {
        "value": "1",
        "unit": "KiB"
      },
      {
        "value": "512",
        "unit": "B"
      }
    ],
    "to": "B"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/bytesize-add/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"terms":[{"value":"1","unit":"KiB"},{"value":"512","unit":"B"}],"to":"B"}'
```

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

### CLI

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

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

## Related tools

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