Skip to content
/ is_close Public

determine whether two floating point numbers are close in value

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

PM4Rs/is_close

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

is_close

Determine whether floating point numbers are close in value

Build Status Crate API License Downloads

In scenarios such as testing it is often times more useful to know whether two floating point numbers are close to each other rather than exactly equal. Due to finite precision of computers, we usually cannot even expect bitwise equality of two values even if underlying math suggests it. This is where is_close comes into play. This crate is strongly inspired by Python PEP 485 aka math.isclose.

Usage

#[macro_use]
extern crate is_close;

assert!(is_close!(42.0, 42.0));
assert!(all_close!(vec![9.0, 10.0], vec![9.0, 10.0]));
assert!(any_close!(vec![0.0, 10.0], vec![9.0, 10.0]));

You'll find plenty of examples at our documentation.

License

Copyright © 2020 The promi Developers

is_close is licensed under MIT OR Apache 2.0 license

About

determine whether two floating point numbers are close in value

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages