harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Bornstein <danf...@google.com>
Subject Re: Float/Double comparison performance
Date Fri, 01 May 2009 18:14:14 GMT
On Fri, May 1, 2009 at 4:33 AM, Egor Pasko <egor.pasko@gmail.com> wrote:
> // Non-zero and non-NaN equality checking.
> if (float1 == float2 && (0.0f != float1 || 0.0f != float2)) {
>  return 0;
> }

Would the following be a useful and safe improvement over the above?:

    if (float1 == float2 && 0.0f != (float1 + float2)) {

I think this would save at least one test and branch. I'm not an
IEEE754 expert, but I think that, given that the two floats are ==,
the second test could only be true if they are both zeroes.

-dan

Mime
View raw message