Length convert
length-convert · version 1.0.0 · Units & sizes · free, no key needed
Convert a canonical integer length between exact SI and international customary units.
Use when you need to: length convert · convert length units · convert integer length between units.
Supported
- length convert
- convert length units
- convert integer length between units
Not supported
- nautical miles
- survey feet
- SI prefixes other than nm um mm cm m km
- floating-point lengths
Behavior
- value is a canonical integer string amount in the from unit and may be negative.
- from and to are exactly one of nm, um, mm, cm, m, km, in, ft, yd, mi using the LENGTH_NM table.
- The result is the reduced rational (value * from_nm) / to_nm expressed in to units.
- Sign lives only on the numerator; zero is numerator 0 over denominator 1.
- Input integers and the reduced numerator and denominator may have at most 1000 digits excluding sign.
Input
value(string, required): max length 1001; pattern^-?(0|[1-9][0-9]*)$from(one of "nm", "um", "mm", "cm", "m", "km", "in", "ft", "yd", "mi", required)to(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
- units: ["nm","um","mm","cm","m","km","in","ft","yd","mi"]
Example
Request input:
{
"value": "1",
"from": "ft",
"to": "in"
}
Response:
{
"result": {
"numerator": "12",
"denominator": "1"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "length-convert",
"version": "1.0.0",
"input": {
"value": "1",
"from": "ft",
"to": "in"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/length-convert/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"value":"1","from":"ft","to":"in"}'
The machine-readable contract is at /v1/tools/length-convert/versions/1.0.0.
CLI
node cli.mjs run length-convert 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Byte size convert: Convert a non-negative integer byte size between IEC binary units as an exact rational.
- Length compare: Compare two integer length measurements by exact nanometer amounts.
- Mass convert: Convert a canonical integer mass amount between exact nanogram-based units as a reduced rational.
- Temperature convert: Convert a decimal temperature between Celsius, Fahrenheit, and Kelvin as an exact rational.
- Length add: Add integer length terms in mixed units and return the exact sum in a chosen unit.
- Mass add: Add mixed-unit canonical integer mass amounts and express the sum in a target unit as a reduced rational.