pub trait FloatExt<T> {
// Required method
fn expand(&self) -> T;
}
Expand description
Adds convenience methods to f32
and f64
.
Required Methods§
sourcefn expand(&self) -> T
fn expand(&self) -> T
Rounds to the nearest integer away from zero, unless the provided value is already an integer.
It is to ceil
what trunc
is to floor
.
§Examples
use kurbo::common::FloatExt;
let f = 3.7_f64;
let g = 3.0_f64;
let h = -3.7_f64;
let i = -5.1_f32;
assert_eq!(f.expand(), 4.0);
assert_eq!(g.expand(), 3.0);
assert_eq!(h.expand(), -4.0);
assert_eq!(i.expand(), -6.0);