floating point conversion

Qox via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 1 06:08:23 PDT 2014


> So it's just a coincidence, that GDC, LDC x86 and also DMD 
> x86_64
> doesn't fail ?

(Equality) Compareision of float/float or float/double are 
machine dependent (depends even on x86 on the generated code 
(SSE/SSE2/AVX/AVX2), rounding settings, maybe event the cpu 
vendor etc.).
On other platforms (ARM, etc) it could be even more weird.

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.


More information about the Digitalmars-d-learn mailing list