Crates.io | assert-eq-float |
lib.rs | assert-eq-float |
version | 0.1.4 |
source | src |
created_at | 2023-03-30 08:51:25.878357 |
updated_at | 2024-03-19 08:24:05.884681 |
description | This crate provides the `assert_eq_float!` macros that support floats. |
homepage | https://magiclen.org/assert-eq-float |
repository | https://github.com/magiclen/assert-eq-float |
max_upload_size | |
id | 824866 |
size | 12,291 |
This crate provides the assert_eq_float!
macros that support floats.
use assert_eq_float::*;
assert_eq_float!(1.1 + 0.1, 1.2); // error = 0.0000000000000021316282072803005
assert_eq_float!(1e100 + 2e100, 3e100); // error = 53290705182007510000000000000000000000000000000000000000000000000000000000000000000000
// other macros
debug_assert_eq_float!(0.0, 0.0);
assert_ne_float!(0.0, 0.1);
debug_assert_ne_float!(0.0, 0.1);
The default margin of error is dynamically computed by properties of IEEE 754 floating point numbers. You don't need to worry about it if you just want to check two float values are equal.
https://crates.io/crates/assert-eq-float
https://docs.rs/assert-eq-float