Hi,
in defense of the current spec, integer arithmetic is signed by default
and unsigned behavior is evident from the method names, like
Long::compareUnsigned or Long::divideUnsigned
But your spec is even clearer ;-)
Greetings
Raffaello
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