Function trunc

Source
pub fn trunc(x: f64) -> f64
🔬This is a nightly-only experimental API. (core_float_math)
Expand description

Experimental version of trunc in core. See f64::trunc for details.

§Examples

#![feature(core_float_math)]

use core::f64;

let f = 3.7_f64;
let g = 3.0_f64;
let h = -3.7_f64;

assert_eq!(f64::trunc(f), 3.0);
assert_eq!(f64::trunc(g), 3.0);
assert_eq!(f64::trunc(h), -3.0);

This standalone function is for testing only. It will be stabilized as an inherent method.