Is comparing against 0.0 safe?
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Tue Feb 15 13:15:00 GMT 2000
When using -Wfloat-equal, I'm getting one warning from gcc
which says: "warning: comparing floating point with == or != is
unsafe".
The code in question is in gcc.c:
> #ifdef HAVE_GETRUSAGE
> struct timeval d;
> double ut = 0.0, st = 0.0;
> #endif
>
> [...]
>
> #ifdef HAVE_GETRUSAGE
> if (report_times && ut + st != 0) <---------------- HERE
> notice ("# %s %.2f %.2f\n", commands[j].prog, ut, st);
> #endif
I was wondering if comparing a float or double against 0.0 is okay
for all platforms and floating point representations.
If so, I'd like to change the warning to allow this.
Otherwise, perhaps I should change the expression to be (ut + st > 0).
--Kaveh
--
Kaveh R. Ghazi Engagement Manager / Project Services
ghazi@caip.rutgers.edu Qwest Internet Solutions
More information about the Gcc
mailing list