Function rufl::math::round_down
source · pub fn round_down<T>(number: T, n: usize) -> T
Expand description
Round down and truncate off n
decimal places to number.
§Arguments
-
number
- The number to round and truncate. -
n
- n digits after decimal point.
§Returns
Rounded number.
§Examples
use rufl::math;
let pi: f64 = std::f64::consts::PI;
assert_eq!(math::round_down(pi, 0), 3.0);
assert_eq!(math::round_down(pi, 1), 3.1);
assert_eq!(math::round_down(pi, 2), 3.14);
assert_eq!(math::round_down(pi, 3), 3.141);
assert_eq!(math::round_down(pi, 4), 3.1415);