The units of measure's Convert: an amount in one unit, in another of the same base unit. It reads the two units in the caller's tenant, as the caller, and changes nothing.
It is the Ash action UnitOfMeasure.convert (run/3), which the REST
API (GET …/unit_of_measure/convert?amount=2&from=KG&to=G) and the MCP
tool run_resource_calculation run, and the page's Convert button
(handle_action/4) runs that same action.
Summary
Functions
amount of from in to: {:ok, decimal}, or {:error, message} when
the two have different base units or to has a factor of 0. The Unit
converter in the Workbench uses it too.
What an Ash error from a convert action says, for the action's dialog: each error's
own message (KG and L have different base units), not the error's
report with its bread crumbs.
A decimal as it is: no trailing zeros, no exponent.
A unit conversion's result as the converter shows it: at most
12 significant digits, but every digit before the point,
with no trailing zeros and no exponent. A division by a factor such as
453.59237 (G to LB) runs to Decimal's 28 digits, more than any reader
needs; an amount the reader typed is shown with show/1, as it is.
Functions
amount of from in to: {:ok, decimal}, or {:error, message} when
the two have different base units or to has a factor of 0. The Unit
converter in the Workbench uses it too.
What an Ash error from a convert action says, for the action's dialog: each error's
own message (KG and L have different base units), not the error's
report with its bread crumbs.
A decimal as it is: no trailing zeros, no exponent.
A unit conversion's result as the converter shows it: at most
12 significant digits, but every digit before the point,
with no trailing zeros and no exponent. A division by a factor such as
453.59237 (G to LB) runs to Decimal's 28 digits, more than any reader
needs; an amount the reader typed is shown with show/1, as it is.