Need reviewer: JDK 8 CR for Support Integer overflow
joe.darcy at oracle.com
Fri Feb 3 09:07:59 PST 2012
On 02/03/2012 06:44 AM, Florian Weimer wrote:
> * Roger Riggs:
>> The boolean expression can be refactored. (Only bit-31 is significant).
>> But it becomes pretty inscrutable.
>> (x ^ r)< 0&& (x ^ y)>= 0 becomes
>> (x ^ r)< 0&& (~(x ^ y))< 0 becomes
>> ((x ^ r)& ~(x ^ y))< 0
> That's what I got in my second attempt, too. It doesn't result in a
> longer dependency chain because the left side of the& is two operations
> deep, too. Therefore, this version should be faster (at least after
> compilation), independent of the input arguments.
These sorts of concerns and lovingly (and laboriously!) detailed to Hank
Warren's bit-twiddling tome "Hacker's Delight"
Roger's initial code used one of the recommend idioms from that source.
We should stick with those idioms unless there is a good reason not to.
More information about the core-libs-dev