On Fri, 8 Jul 2022 06:11:22 GMT, Joe Darcy <da...@openjdk.org> wrote:
> Initial implementation. src/java.base/share/classes/java/lang/Float.java line 1003: > 1001: float abs_f = Math.abs(f); > 1002: int doppel = Float.floatToRawIntBits(f); > 1003: int f_sign = 0x8000_0000 & doppel; The code would be a bit less branchy if sign were computed like this: short sign_bit = (short)((doppel >> 16) & 0x8000); and get rid of `f_sign`; instead of conditionals in various places use bitwise or of `sign_bit`, such as: if (abs_f > 65504.0f ) { return (short)(sign_bit | 0x7c00); // Positive or negative infinity } I'm mainly looking forward to what the JIT produces, but I also think handling the sign in this way makes the code at least as easy to understand as the current branch-based exposition. ------------- PR: https://git.openjdk.org/jdk/pull/9422