pub(crate) fn round_to_decimal_places(value: f64, decimal_places: u32) -> f64Expand description
Universal rounding function that rounds a floating-point number to the specified number of decimal places and returns f64.
For 1 decimal place (priorities): Only rounds when within floating-point error tolerance to preserve legitimate decimals like 0.25.
For other decimal places: Always rounds to the specified precision.
§Arguments
value- The floating-point number to rounddecimal_places- Number of decimal places to round to (default: 1)
§Examples
ⓘ
round_to_decimal_places(0.6000000000000001, 1) // → 0.6
round_to_decimal_places(0.25, 1) // → 0.25 (preserved)
round_to_decimal_places(33.333333333333336, 4) // → 33.3333
round_to_decimal_places(10.0, 4) // → 10.0