On Sun, 19 Aug 2007, chromatic wrote: > On Sunday 19 August 2007 17:32:01 Andy Dougherty wrote: > > > On Sat, 18 Aug 2007, [EMAIL PROTECTED] wrote: > > > > Log: > > > Added FLOAT_IS_ZERO() macro to parrot/misc.h for comparing floats to > > > zero. This may need some attention on platforms where INTVAL isn't four > > > bytes, but I did the best I could. > > > > Stepping back a moment, I don't think this is a good idea. The original > > code, > > f == 0.0 > > is perfectly clear and quite well-defined. I think the compiler warning > > should simply be turned off. It isn't doing anything useful here. > > For the zero case or for all floating point comparisons? If it's not useful > for the zero case, can we disable it for just that one?
I don't know how to disable it for just some cases. Broadly speaking, I see three use cases in the source: f == 0.0 $1 == $2 (in cmp.ops, for example) miscellaneous Your trick (extended, if needed, by clever Configure.pl probes) will cleverly suppress the warning for the f == 0 case, while still retaining the exact comparison. (Hmm. Not sure about negative zero offhand. I'd have to test.) The $1 == $2 ones in cmp.ops could similarly be disabled by comparing bit patterns in a way to fool the warning. (I'm assuming, by the way, that you're not thinking of replacing the cmp.ops equality tests by some sort of fuzzy equality test. I'd have no objection to *adding* some fuzzy ops, but if I ask parrot to test '==', I want it to do just that.) That would leave the miscellaneous ones. Specifically, I see things like the following: src/pmc/complex.pmc:1144 if (im == 4.0 * atan(1.0)) src/pmc/string.pmc:448 return (INTVAL)(sf == vf); compilers/imcc/optimizer.c:434 atof(ins->r[1]->name) == 1.0)) { compilers/imcc/optimizer.c:456 atof(ins->r[1]->name) == 1.0)) { compilers/imcc/optimizer.c:505 atof(ins->r[2]->name) == 1.0) compilers/imcc/optimizer.c:507 atof(ins->r[1]->name) == 1.0)) { I don't understand the point of the imcc ones but they look harmless. The others all look legitimate too. In short: I suspect you're going to end up working to suppress every single one of those warnings anyway. Still, as long as you actually continue to test for equality (and not some fuzzy near-equality) I don't see any harm to it either. I withdraw my objections. -- Andy Dougherty [EMAIL PROTECTED]