round_to
Rounds value to decimals decimal places, half away from zero.
The result is the nearest f64 to the rounded decimal, so it can still print with more digits
than requested for some values, and binary representation applies: 1.005 is stored as
1.00499999999999989…, so round_to(1.005, 2) is 1.0. NaN, infinities, and values too
large to scale are returned unchanged.
Import
Section titled “Import”Cargo feature number (enabled by default). To compile only this module:
or in Cargo.toml:
Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | f64 | The number to round. |
decimals | u32 | How many decimal places to keep. |
Returns
Section titled “Returns”f64
