On 7/7/2021 5:43 PM, Brian Burkhalter wrote:
On Thu, 8 Jul 2021 00:38:45 GMT, Joe Darcy <da...@openjdk.org> wrote:

Please consider this change to make the `float` and `double` versions of 
`java.lang.Math.abs()` branch-free.
src/java.base/share/classes/java/lang/Math.java line 1530:

1528:     @IntrinsicCandidate
1529:     public static float abs(float a) {
1530:         return Float.intBitsToFloat(Float.floatToRawIntBits(a) & 
0x7fffffff);
I'd like to see a brief comment on these methods along the lines of "zero out sign 
bit in the representation." Using underscores in the literal to better group the 
digits or using the constants in jdk.internal.math.DoubleConsts.
There is no specific constant in `{Float,Double}Consts` to mask all but the 
sign bit, but I had thought it might be good to add one there


The sign bit mask can be bit-wise complemented though :-)

-Joe

Reply via email to