On Mon, Aug 20, 2007 at 05:26:22PM -0400, Andy Dougherty wrote: > > I can't think of a clean, portable, efficient way to test that a floating > > point variable is zero other than == 0.0; > > Nor can I. Thus you either use lots of platform-specific code (determined > by Configure.pl) or turn off gcc's -Wfloat-equal warning flag and just > write f == 0.0. > > Personally, I'd just turn off the -Wfloat-equal flag, but I have no > objection if someone else wants to do all the work to do it the other way.
FWIW, I'm in favor of turning off the -Wfloat-equal flag and using the f == 0.0 test. Using f == 0.0 * immediately obvious to understand * portable * correct * more efficient * less code Somehow I have difficulty seeing that the benefit (potentially catching a few floating point equality comparisons) is worth compromising on all of the above. Pm