The original article which used to be here is obsolete. Its replacement - which fixes some errors and better explains the relevant issues - was crafted as a multi-part series here. Please update your links.

Some of the problems with the original code include aliasing problems, integer overflow, and an attempt to extend the ULPs based technique further than really makes sense. The series of articles linked above covers the whole topic, but the key article that demonstrates good techniques for floating-point comparisons can be found here. This article also includes a cool demonstration, using sin(double(pi)), of why the ULPs technique and other relative error techniques breaks down around zero.

In short, stop reading. Click this link.




If you want to see the original article, in all its faded glory, just click on obsolete techniques, but really you'd be better off clicking on Awesome Floating Point Comparisons.