Open workhorsy opened 3 years ago
Comparing equality of different floating points is a bad idea.
Fails on LDC from precision loss between string and double:
import std.conv : to; ("13.1").to!double.shouldEqual(13.1);
Comparing double to float fails:
(13.1f).shouldEqual(13.1);
Use std.math.isClose instead: https://dlang.org/phobos/std_math_operations.html#isClose
(13.1f).shouldBeClose(13.1); (13.1f).shouldBeClose(13.1, 1e-9);
Also make shouldEqual fail to compile with floating point numbers, and recommend shouldBeClose instead.
shouldEqual
shouldBeClose
Comparing equality of different floating points is a bad idea.
Fails on LDC from precision loss between string and double:
Comparing double to float fails:
Use std.math.isClose instead: https://dlang.org/phobos/std_math_operations.html#isClose
Also make
shouldEqual
fail to compile with floating point numbers, and recommendshouldBeClose
instead.