Mass add
mass-add · version 1.0.0 · Units & sizes · free, no key needed
Add mixed-unit canonical integer mass amounts and express the sum in a target unit as a reduced rational.
Use when you need to: mass add · add mass quantities · sum masses in mixed units.
Supported
- mass add
- add mass quantities
- sum masses in mixed units
Not supported
- mass multiply
- average mass
- density from mass and volume
- troy or stone units
- floating-point mass
Behavior
- terms is an array of 1 to 32 objects, each 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 term is converted to nanograms as BigInt and the nanogram amounts are summed.
- The sum is converted to the to unit as the reduced rational sum_ng / to_ng.
- Negative term values are allowed; -0 canonicalizes to 0.
- Unknown fields, unknown units, empty or overlong terms arrays, and reduced results over 1000 digits are rejected.
Input
terms(array of object, required): min items 1; max items 32to(one of "ng", "ug", "mg", "g", "kg", "t", "oz", "lb", 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
Example
Request input:
{
"terms": [
{
"value": "1",
"unit": "kg"
},
{
"value": "500",
"unit": "g"
}
],
"to": "g"
}
Response:
{
"result": {
"numerator": "1500",
"denominator": "1"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "mass-add",
"version": "1.0.0",
"input": {
"terms": [
{
"value": "1",
"unit": "kg"
},
{
"value": "500",
"unit": "g"
}
],
"to": "g"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/mass-add/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"terms":[{"value":"1","unit":"kg"},{"value":"500","unit":"g"}],"to":"g"}'
The machine-readable contract is at /v1/tools/mass-add/versions/1.0.0.
CLI
node cli.mjs run mass-add 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Byte size add: Add non-negative integer byte-size terms in mixed IEC units and return the exact sum in a chosen unit.
- Length add: Add integer length terms in mixed units and return the exact sum in a chosen unit.
- Mass compare: Compare two mixed-unit canonical integer mass amounts using exact nanogram BigInt values.
- Mass convert: Convert a canonical integer mass amount between exact nanogram-based units as a reduced rational.
- Byte size convert: Convert a non-negative integer byte size between IEC binary units as an exact rational.
- Length convert: Convert a canonical integer length between exact SI and international customary units.