Ian Rogers wrote: > 2009/6/24 Tim Ellison <[email protected]>: >> 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
