cubit
A dimensional-analysis calculator
Units, typed products and exact conversions, as a command line tool and a web app.
Exact conversions
Built on uom. :exact on makes decimals exact, so 0.1 m + 0.2 m is 0.3 m.
Typed products
A product is typed where uom declares a relation (Force · Length is an Energy). -v shows the type and the dimension.
Dimension errors
A sum of different dimensions is an error that names both: cannot add Length [L] and Time [T].
$ cubit '3 kN * 2 m to J'
6000.0 J
$ cubit -v '10 mi / 2 h to km/h'
8.04672 km/h
Speed [L·T^-1]
$ cubit '3 m + 2 s'
error: cannot add Length [L] and Time [T]
cubit needs Java 25 or later. With jbang no build is needed, and the same jar serves the web app:
jbang cubit@TinyGearsOrg/cubit '20 °C to °F'
jbang cubit@TinyGearsOrg/cubit --serve # http://localhost:8080
A cubit is an old unit of length, the span of a forearm. See the README for the expression language, variables and your own units.