floating point comparison basics

bearophile bearophileHUGS at lycos.com
Tue Dec 3 17:52:07 PST 2013


H. S. Teoh:

> The first rule of floating-point comparisons is that you never 
> use ==.

So I suggested to disallow the == among FP numbers in D (and 
allow FP comparisons with "is" or with specialized functions, 
including one function that does what == does today).


For the original poster, for general FP comparisons I suggest 
std.math.feqrel, it's not fast, it's not const-correct, but it's 
good.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list