src/java.base/share/classes/java/lang/StrictMath.java
Print this page
rev 12758 : 5100935: No way to access the 64-bit integer multiplication of 64-bit CPUs efficiently
Summary: Add a method to produce the high 64 bits of two 64-bit longs multiplied into a 128-bit long.
Reviewed-by: XXX
@@ -828,10 +828,38 @@
public static int toIntExact(long value) {
return Math.toIntExact(value);
}
/**
+ * Returns the product of the arguments allowing overflowed values within
+ * the range of {@code long}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @see Math#multiplyFull(long,long)
+ * @since 1.9
+ */
+ public static long multiplyFull(int x, int y) {
+ return Math.multiplyFull(x, y);
+ }
+
+ /**
+ * Returns as a {@code long} the most significant 64 bits of the 128-bit
+ * product of two 64-bit factors.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @see Math#multiplyHigh(long,long)
+ * @since 1.9
+ */
+ public static long multiplyHigh(long x, long y) {
+ return Math.multiplyHigh(x, y);
+ }
+
+ /**
* Returns the largest (closest to positive infinity)
* {@code int} value that is less than or equal to the algebraic quotient.
* There is one special case, if the dividend is the
* {@linkplain Integer#MIN_VALUE Integer.MIN_VALUE} and the divisor is {@code -1},
* then integer overflow occurs and