John Cowan wrote:
The expression "f != 0.0 && f == f + f" will work, I think.
0.0 and NaN are rejected by the left side of "&&", and all
other finite values by the right side.

Thinking about it some more I think that "!isnan(f) && isnan(f-f)" (given John's definition of isnan()) might be an even better way to do this. f-f can never be nan on an IEEE float system unless f is either nan or inf. And with non-IEEE floats this test should always fail because (presumably) f==f will always be true and hence isnan will always be false. Right?

This test only relies on the algebraic properties of inf and nan and should be about the most efficient way to do it, too, as it just needs a single subtraction and two comparisons.

--
Dr. Albert Gr"af
Dept. of Music-Informatics, University of Mainz, Germany
Email:  [EMAIL PROTECTED], [EMAIL PROTECTED]
WWW:    http://www.musikinformatik.uni-mainz.de/ag


_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to