floating point conversion

Wanderer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 1 09:47:13 PDT 2014


> The General rule is not to compare floats for equality, (is 
> 0.0==-0.0, etc.). Use a epsilon based comparision scheme 
> instead or a wrapper around it.

That's not exactly true. You cannot (and should not) compare 
floating points for equality, and use epsilon-based comparison 
instead, only in one certain case: when one of the arguments if 
the result of computation, during which a computational error 
might accumulate.

If you have two exact or constant values, comparing them directly 
is perfectly fine. :-) Nowadays floating-point hardware support 
is not that "buggy".


More information about the Digitalmars-d-learn mailing list