Function cmp_floats::cmp_floats [−][src]
pub fn cmp_floats<T, U>(f1: T, f2: U) -> Ordering where
T: Into<f64>,
U: Into<f64>,
Compares 2 values and returns an std::cmp::Ordering
.
Values must implement Into<f64>
Examples
use std::cmp::Ordering::*; use cmp_floats::cmp_floats; assert_eq!(Less, cmp_floats(2.71828f32, 3.14159f64)); let a: f32 = 0.15 + 0.15 + 0.15; let b: f32 = 0.1 + 0.1 + 0.25; assert_eq!(Equal, cmp_floats(a, b));