pub fn round_f64(value: f64, decimals: u32) -> f64Expand description
Round a floating point value to decimals decimal places.
ยงExamples
use tokmd_math::round_f64;
assert_eq!(round_f64(12.34567, 2), 12.35);
assert_eq!(round_f64(12.34567, 4), 12.3457);
assert_eq!(round_f64(1.5, 0), 2.0);Rounding at zero decimal places:
use tokmd_math::round_f64;
assert_eq!(round_f64(2.4, 0), 2.0);
assert_eq!(round_f64(2.6, 0), 3.0);