Math.mutiplyHigh() is signed

David Lloyd david.lloyd at redhat.com
Tue Jun 23 13:04:12 UTC 2020


In retrospect I don't know why I expected Math.multiplyHigh() to
return the high word of the unsigned product of two 64-bit numbers,
given that long is signed; in my defence however, the docs don't
actually seem to specify.

WDYT about a patch like this to clarify?

diff --git a/src/java.base/share/classes/java/lang/Math.java
b/src/java.base/share/classes/java/lang/Math.java
index 8147b7109e2..552501ca6d7 100644
--- a/src/java.base/share/classes/java/lang/Math.java
+++ b/src/java.base/share/classes/java/lang/Math.java
@@ -1095,8 +1095,8 @@ public final class Math {
     }

     /**
-     * Returns as a {@code long} the most significant 64 bits of the 128-bit
-     * product of two 64-bit factors.
+     * Returns as a {@code long} the most significant 64 bits of the
signed 128-bit
+     * product of two 64-bit signed factors.
      *
      * @param x the first value
      * @param y the second value


-- 
- DML



More information about the core-libs-dev mailing list