[][src]Trait kurbo::common::FloatExt

pub trait FloatExt<T> {
    fn expand(&self) -> T;
}

Adds convenience methods to f32 and f64.

Required methods

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);
Loading content...

Implementations on Foreign Types

impl FloatExt<f64> for f64[src]

impl FloatExt<f32> for f32[src]

Loading content...

Implementors

Loading content...