lorust 0.2.0

Modern Rust utility library delivering modularity, performance & extras; or simply Rust version of Lodash
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/// Computes `number` rounded to `precision`.
///
/// # Examples
///
/// ```rust
/// use lorust::round;
///
/// let rounded = round(4.006, 2);
/// assert_eq!(rounded, 4.01);
/// ```
pub fn round(number: f64, precision: i32) -> f64 {
    let factor = 10.0_f64.powi(precision);
    (number * factor).round() / factor
}