harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Ellison <t.p.elli...@gmail.com>
Subject Re: [luni] Math.max(double, double) gives wrong answer when Math.max(-0.0d, 0.0d) (HARMONY-6242)
Date Wed, 24 Jun 2009 11:46:49 GMT
Ian Rogers wrote:
> 2009/6/24 Tim Ellison <t.p.ellison@gmail.com>:
>> I love these ;-)
>>
>> Ian Rogers (JIRA) wrote:
<snip>
>>> A simple test:
>>>
>>>       System.out.println(Math.max(-0.0d, 0.0d));
>>>
>>> prints -0.0 with Harmony and 0.0 with a non-Harmony classlib.
>>>
>> So is the answer to replace the last test with:
>>
>>  if (Double.doubleToRawLongBits(d1) == Double.doubleToRawLongBits(-0.0d)) {
>>      return d2;
>>  }
>>  return d1;
> 
> I think there are plenty of ways to write it, you could compare
> against the raw long bits of d2. In your code you could just return
> 0.0d rather than d1 at the end which may expose some constant
> propagation. I was wondering if for Intel SSE there'd be some way to
> optimize this to use the MAXSS/MAXSD instructions.

I committed a fix for the incorrect behavior at r787977, if there are
optimizations we can look at those too.

Thanks,
Tim

Mime
View raw message