RFR: 6506405: Math.abs(float) is slow

Brian Burkhalter bpb at openjdk.java.net
Wed Jul 7 21:11:52 UTC 2021


On Wed, 7 Jul 2021 20:28:37 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Please consider this change to make the `float` and `double` versions of `java.lang.Math.abs()` branch-free.

Good catch. Well that’s not good. If it needs to catch a special case it’s probably not worth doing. given the small improvement for the general case. None of the existing tests catch this corner case.

On Jul 7, 2021, at 2:03 PM, Rémi Forax ***@***.******@***.***>> wrote:


Your patch change the semantics, actually
Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE
with your patch
Math.abs(Integer.MIN_VALUE) == Integer.MAX_VALUE

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<https://urldefense.com/v3/__https://github.com/openjdk/jdk/pull/4711*issuecomment-875931239__;Iw!!ACWV5N9M2RV99hQ!cfR3MocdWRA_0gP-3VpRbM_stXXf7VTtD7tPX9aQ07WkId8ihoEhwiCQ_wUCotsYgmlw$>, or unsubscribe<https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ARBIJVLTH4NIS5WBNTXX26DTWS6KZANCNFSM477LZKTQ__;!!ACWV5N9M2RV99hQ!cfR3MocdWRA_0gP-3VpRbM_stXXf7VTtD7tPX9aQ07WkId8ihoEhwiCQ_wUCotXRvaVx$>.

-------------

PR: https://git.openjdk.java.net/jdk/pull/4711


More information about the core-libs-dev mailing list