Decimal subtract
decimal-subtract · version 1.0.0 · Numbers & math · free, no key needed
Exact decimal subtraction a minus b of canonicalizable decimal strings.
Use when you need to: decimal subtract · subtract decimals · exact decimal difference.
Decide before calling
Read the versioned contract and the supported scope below. Reuse decimal-subtract@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use decimal-subtract@1.0.0 for decimal subtract. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- decimal subtract
- subtract decimals
- exact decimal difference
Not supported
- ieee754
- currency rounding
- tax
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 a-b.
Input
a(string, required): min length 1; max length 44b(string, required): min length 1; max length 44
Output
value(string, required)
Limits
- max digits: 40
- max scale: 18
Example
Request input:
{
"a": "2.00",
"b": "0.1"
}
Response:
{
"result": {
"value": "1.9"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "decimal-subtract",
"version": "1.0.0",
"input": {
"a": "2.00",
"b": "0.1"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/decimal-subtract/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"a":"2.00","b":"0.1"}'
The machine-readable contract is at /v1/tools/decimal-subtract/versions/1.0.0.
CLI
node cli.mjs run decimal-subtract 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Decimal add: Exact decimal addition of canonicalizable decimal strings.
- Capacity allocation check: Check an exact claimed allocation for eligibility and per-bin decimal capacity compliance.
- Decimal compare: Compare two decimal strings exactly after canonicalization.
- Number engineering format: Format an exact decimal in scientific or engineering notation with explicit precision and rounding.
- Permutation ranked check: Check exact stable ordinal ranks for decimal-string values and nulls, reporting the first source-index discrepancy.
- Rational subtract: Subtract one rational number from another, given as numerator/denominator integer strings, and return the reduced difference.