Length add
length-add · version 1.0.0 · Units & sizes · free, no key needed
Add integer length terms in mixed units and return the exact sum in a chosen unit.
Use when you need to: length add · add length measurements · sum length terms into a unit.
Supported
- length add
- add length measurements
- sum length terms into a unit
Not supported
- more than 32 terms
- nautical miles
- floating-point lengths
- mean of lengths
Behavior
- terms is an array of 1 to 32 objects, each with a canonical integer value and a length unit.
- Each term is converted to nanometers as a BigInt and those amounts are summed.
- The nanometer sum is converted to the to unit as a reduced canonical rational.
- Negative term values are allowed; input -0 is canonicalized to 0.
- Input integers and the reduced numerator and denominator may have at most 1000 digits excluding sign.
Input
terms(array of object, required): min items 1; max items 32to(one of "nm", "um", "mm", "cm", "m", "km", "in", "ft", "yd", "mi", 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: ["nm","um","mm","cm","m","km","in","ft","yd","mi"]
Example
Request input:
{
"terms": [
{
"value": "1",
"unit": "ft"
},
{
"value": "6",
"unit": "in"
}
],
"to": "in"
}
Response:
{
"result": {
"numerator": "18",
"denominator": "1"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "length-add",
"version": "1.0.0",
"input": {
"terms": [
{
"value": "1",
"unit": "ft"
},
{
"value": "6",
"unit": "in"
}
],
"to": "in"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/length-add/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"terms":[{"value":"1","unit":"ft"},{"value":"6","unit":"in"}],"to":"in"}'
The machine-readable contract is at /v1/tools/length-add/versions/1.0.0.
CLI
node cli.mjs run length-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 compare: Compare two integer length measurements by exact nanometer amounts.
- Mass add: Add mixed-unit canonical integer mass amounts and express the sum in a target unit as a reduced rational.
- Length convert: Convert a canonical integer length between exact SI and international customary units.
- Byte size compare: Compare two non-negative integer byte sizes by exact byte amounts.
- Byte size convert: Convert a non-negative integer byte size between IEC binary units as an exact rational.