pub trait F64Ext {
// Required method
fn round_decimal_places(self, _: u32) -> f64;
}
Required Methods§
sourcefn round_decimal_places(self, _: u32) -> f64
fn round_decimal_places(self, _: u32) -> f64
Round a number to a certain amount of decimal places.
Arguments
self
- The value to round.decimal_places
- The amount of decimal places to round this to.
Returns
The rounded value.
Examples
use libhealth::utils::prelude::*;
let val: f64 = 13.54231;
assert_eq!(val.round_decimal_places(1), 13.5);
assert_eq!(val.round_decimal_places(2), 13.54);