On Thu, 27 Feb 2003, Jeroen Frijters wrote: > Hi, > > Attached is a small patch to java.lang.Math to make round(float) and > round(double) do the right thing for NaN. > > Style wise, is it a good idea to use "a != a" to test for NaN, or should > Double.isNaN() be used?
This is an old chestnut. ;) For some VMs, Double.isNaN() will translate to an (expensive) JNI method call. For others it's no big deal. So on the whole "a != a" seems like the better bet. Hm, I see Wonka's java.lang.Math contains 21 "a != a" constructs and 2 "Double.isNaN(a)"'s. :-/ What we really need is #define isNaN(a) ((a) != (a)) ;> -- Chris Gray VM Architect, ACUNIA _______________________________________________ Classpath mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/classpath

