Skip to main content

convert

Function convert 

Source
pub fn convert(val: f64, from: &str, to: &str) -> Result<f64, UnitError>
Expand description

Convert a value from one unit to another.

Both units must belong to the same quantity (e.g. both are lengths). Units can be specified by name ("fahrenheit") or symbol ("°F").

§Precision

Conversions use IEEE 754 double-precision arithmetic. Chained conversions (e.g., °F → °C → K → °F) may accumulate floating-point error on the order of ±1e-10. For exact round-trip fidelity, convert directly between source and target units rather than through intermediaries.