# Decimal add

`decimal-add` · version 1.0.0 · Numbers & math · free, no key needed

Exact decimal addition of canonicalizable decimal strings.

**Use when you need to: decimal add · add decimals · exact decimal sum.**

## Supported

- decimal add
- add decimals
- exact decimal sum

## Not supported

- ieee754
- currency rounding
- tax
- interest

## Behavior

- Input decimal strings: /^-?(0|[1-9][0-9]*)(\.[0-9]+)?$/.
- Reject leading zeros, plus signs, spaces, exponents, bare ".", trailing ".", empty, and NaN/Infinity tokens.
- At most 40 digits excluding sign and decimal point. At most 18 fractional digits on input.
- Canonicalize: strip trailing fractional zeros; drop the decimal point if the fraction vanishes; normalize -0 and -0.0 to "0".
- Exact decimal arithmetic with BigInt scaled integers. No IEEE-754 intermediates. Never return JSON BigInt.
- Return canonical sum. Intermediate scale is the max of operand scales, then canonicalize.

## Input

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

## Output

- `value` (string, required)

## Limits

- max digits: 40
- max scale: 18

## Example

Request input:

```json
{
  "a": "1.50",
  "b": "0.5"
}
```

Response:

```json
{
  "result": {
    "value": "2"
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "decimal-add",
  "version": "1.0.0",
  "input": {
    "a": "1.50",
    "b": "0.5"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/decimal-add/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"a":"1.50","b":"0.5"}'
```

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

### CLI

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

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

## Related tools

- [Decimal subtract](/tools/decimal-subtract): Exact decimal subtraction a minus b of canonicalizable decimal strings.
- [Array rational sum](/tools/array-rational-sum): Sum an array of canonical rationals and return the reduced total.
- [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.
- [Rational add](/tools/rational-add): Add two rational numbers given as numerator/denominator integer strings and return the reduced sum.
- [Array integer cumulative sum](/tools/array-integer-cumulative-sum): Replace an array of canonical integer strings with equal-length prefix sums.
