[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Math patch
From: |
Chris Gray |
Subject: |
Re: Math patch |
Date: |
Thu, 27 Feb 2003 13:29:45 +0100 (CET) |
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