On Saturday, 16 November 2019 at 10:01:25 UTC, Avery Stupidman
wrote:
assert(angleDeg(sqrt(3.0)/2.0, 1.5) == 60.0); // Fails
On my computer the results are very close, that is:
import std.math: nextUp;
assert(nextUp(angleDeg(sqrt(3.0)/2.0, 1.5)) == 60.0); // OK
On Saturday, 16 November 2019 at 10:17:12 UTC, drug wrote:
you can use something like approxEqual
https://dlang.org/library/std/math/approx_equal.html
With approxEqual, one needs to be very carefull. The default
parameters allow for very odd results, accepting values to be
equal, which are actually far apart considering the precision
available; this is especially true, when using double or real.
For example, here are about 12 significant fractional digits
involved, which are completely ignored:
assert(approxEqual(100.0,101.0)); // OK
I wrote a replacement with better handling of the default
parameters [1], but it looks like no one wants to take the burden
to review it, probably because that would involve to make a
decision. (Or maybe it has some other reasons I do not see.)
[1] https://github.com/dlang/phobos/pull/7241