#floats #cmp #compare #order

yanked cmp_floats

A function to compare floats

0.1.7 Feb 21, 2021
0.1.6 Feb 21, 2021

#25 in #cmp

MIT license

4KB

cmp_floats

This is a function I made, because other float comparison libraries seemed unnecessarily complicated.

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));

No runtime deps