pub fn cmp_float_nan<F: Float>(a: F, b: F) -> Ordering
Expand description
Compare 2 floats, NaN
’s will always return Ordering::Equal
.
assert_eq!(cmp_float_nan(0.0, 1.0), Ordering::Less);
assert_eq!(cmp_float_nan(1.0, 1.0), Ordering::Equal);
assert_eq!(cmp_float_nan(2.0, 1.0), Ordering::Greater);
assert_eq!(cmp_float_nan(1.0, f32::INFINITY), Ordering::Less);
assert_eq!(cmp_float_nan(f32::INFINITY, f32::INFINITY), Ordering::Equal);
assert_eq!(cmp_float_nan(f32::INFINITY, 1.0), Ordering::Greater);
assert_eq!(cmp_float_nan(f32::NEG_INFINITY, f32::INFINITY), Ordering::Less);
assert_eq!(cmp_float_nan(f32::NEG_INFINITY, f32::NEG_INFINITY), Ordering::Equal);
assert_eq!(cmp_float_nan(f32::INFINITY, f32::NEG_INFINITY), Ordering::Greater);
assert_eq!(cmp_float_nan(f32::NAN, -0.0), Ordering::Equal);
assert_eq!(cmp_float_nan(f32::NAN, 0.0), Ordering::Equal);
assert_eq!(cmp_float_nan(f32::NAN, f32::NAN), Ordering::Equal);
assert_eq!(cmp_float_nan(f32::NAN, f32::INFINITY), Ordering::Equal);
assert_eq!(cmp_float_nan(f32::NAN, f32::NEG_INFINITY), Ordering::Equal);