cmp_floats

Crates.iocmp_floats
lib.rscmp_floats
version0.1.7
sourcesrc
created_at2021-02-08 20:05:10.402273
updated_at2021-02-21 14:21:40.546145
descriptionA function to compare floats
homepage
repositoryhttps://github.com/47617272696e/cmp_floats
max_upload_size
id352471
size4,587
(Small-Person)

documentation

https://docs.rs/cmp_floats/0.1.0/cmp_floats/

README

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));
Commit count: 0

cargo fmt