floating point comparison basics
ed
sillymongrel at gmail.com
Tue Dec 3 20:44:58 PST 2013
On Wednesday, 4 December 2013 at 01:52:09 UTC, bearophile wrote:
> 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
Thanks, I will look into it.
I've implemented my comparison function and it gives the same
results as approxEquals ... yay! ...only took me several hours to
achieve about 10 LOC but I finally understand it
Cheers,
Ed
More information about the Digitalmars-d-learn
mailing list