pub trait Float {
// Required methods
fn round_dp(self, decimal_places: u32) -> Self;
fn ceil_dp(self, decimal_places: u32) -> Self;
fn floor_dp(self, decimal_places: u32) -> Self;
}Required Methods§
Sourcefn round_dp(self, decimal_places: u32) -> Self
fn round_dp(self, decimal_places: u32) -> Self
Rounds the number to the given number of decimal places
§Examples
use common_math::rounding::*;
assert_eq!(123.456_f64.round_dp(2), 123.46_f64);
assert_eq!(123.456_f64.round_dp(0), 123_f64);
assert_eq!(123.456_f32.round_dp(2), 123.46_f32);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.