diff --git a/src/java.base/share/classes/java/lang/Math.java b/src/java.base/share/classes/java/lang/Math.java index 4f69b67a058..4540aceea49 100644 --- a/src/java.base/share/classes/java/lang/Math.java +++ b/src/java.base/share/classes/java/lang/Math.java @@ -1247,7 +1247,7 @@ public final class Math { /** * 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 + * There is one special case: if the dividend is * {@linkplain Integer#MIN_VALUE Integer.MIN_VALUE} and the divisor is {@code -1}, * then integer overflow occurs and * the result is equal to {@code Integer.MIN_VALUE}. @@ -1256,14 +1256,16 @@ public final class Math { * (truncation). This operation instead acts under the round toward * negative infinity (floor) rounding mode. * The floor rounding mode gives different results from truncation - * when the exact result is negative. + * when the exact quotient is not an integer and is negative. *
* For examples, see {@link #floorDiv(int, int)}. * @@ -1319,7 +1321,7 @@ public final class Math { /** * Returns the largest (closest to positive infinity) * {@code long} value that is less than or equal to the algebraic quotient. - * There is one special case, if the dividend is the + * There is one special case: if the dividend is * {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1}, * then integer overflow occurs and * the result is equal to {@code Long.MIN_VALUE}. @@ -1328,7 +1330,7 @@ public final class Math { * (truncation). This operation instead acts under the round toward * negative infinity (floor) rounding mode. * The floor rounding mode gives different results from truncation - * when the exact result is negative. + * when the exact result is not an integer and is negative. *
* For examples, see {@link #floorDiv(int, int)}. * @@ -1353,40 +1355,35 @@ public final class Math { /** * Returns the floor modulus of the {@code int} arguments. *
- * The floor modulus is {@code x - (floorDiv(x, y) * y)}, - * has the same sign as the divisor {@code y}, and + * The floor modulus is {@code r = x - (floorDiv(x, y) * y)}, + * has the same sign as the divisor {@code y} or is zero, and * is in the range of {@code -abs(y) < r < +abs(y)}. * *
* The relationship between {@code floorDiv} and {@code floorMod} is such that: *
- * The difference in values between {@code floorMod} and - * the {@code %} operator is due to the difference between - * {@code floorDiv} that returns the integer less than or equal to the quotient - * and the {@code /} operator that returns the integer closest to zero. + * The difference in values between {@code floorMod} and the {@code %} operator + * is due to the difference between {@code floorDiv} and the {@code /} + * operator, as detailed in {@linkplain #floorDiv(int, int)}. *
* Examples: *
- * If the signs of arguments are unknown and a positive modulus - * is needed it can be computed as {@code (floorMod(x, y) + abs(y)) % abs(y)}. * * @param x the dividend * @param y the divisor @@ -1407,14 +1404,14 @@ public final class Math { /** * Returns the floor modulus of the {@code long} and {@code int} arguments. *
- * The floor modulus is {@code x - (floorDiv(x, y) * y)}, - * has the same sign as the divisor {@code y}, and + * The floor modulus is {@code r = x - (floorDiv(x, y) * y)}, + * has the same sign as the divisor {@code y} or is zero, and * is in the range of {@code -abs(y) < r < +abs(y)}. * *
* The relationship between {@code floorDiv} and {@code floorMod} is such that: *
* For examples, see {@link #floorMod(int, int)}. @@ -1434,14 +1431,14 @@ public final class Math { /** * Returns the floor modulus of the {@code long} arguments. *
- * The floor modulus is {@code x - (floorDiv(x, y) * y)}, - * has the same sign as the divisor {@code y}, and + * The floor modulus is {@code r = x - (floorDiv(x, y) * y)}, + * has the same sign as the divisor {@code y} or is zero, and * is in the range of {@code -abs(y) < r < +abs(y)}. * *
* The relationship between {@code floorDiv} and {@code floorMod} is such that: *
* For examples, see {@link #floorMod(int, int)}. diff --git a/src/java.base/share/classes/java/lang/StrictMath.java b/src/java.base/share/classes/java/lang/StrictMath.java index 427fa7080ba..062e3fd3709 100644 --- a/src/java.base/share/classes/java/lang/StrictMath.java +++ b/src/java.base/share/classes/java/lang/StrictMath.java @@ -1051,10 +1051,10 @@ public final class StrictMath { /** * 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 + * There is one special case: if the dividend is * {@linkplain Integer#MIN_VALUE Integer.MIN_VALUE} and the divisor is {@code -1}, * then integer overflow occurs and - * the result is equal to the {@code Integer.MIN_VALUE}. + * the result is equal to {@code Integer.MIN_VALUE}. *
* See {@link Math#floorDiv(int, int) Math.floorDiv} for examples and * a comparison to the integer division {@code /} operator. @@ -1075,7 +1075,7 @@ public final class StrictMath { /** * Returns the largest (closest to positive infinity) * {@code long} value that is less than or equal to the algebraic quotient. - * There is one special case, if the dividend is the + * There is one special case: if the dividend is * {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1}, * then integer overflow occurs and * the result is equal to {@code Long.MIN_VALUE}. @@ -1099,10 +1099,10 @@ public final class StrictMath { /** * Returns the largest (closest to positive infinity) * {@code long} value that is less than or equal to the algebraic quotient. - * There is one special case, if the dividend is the + * There is one special case: if the dividend is * {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1}, * then integer overflow occurs and - * the result is equal to the {@code Long.MIN_VALUE}. + * the result is equal to {@code Long.MIN_VALUE}. *
* See {@link Math#floorDiv(int, int) Math.floorDiv} for examples and * a comparison to the integer division {@code /} operator. @@ -1123,13 +1123,14 @@ public final class StrictMath { /** * Returns the floor modulus of the {@code int} arguments. *
- * The floor modulus is {@code x - (floorDiv(x, y) * y)}, - * has the same sign as the divisor {@code y}, and + * The floor modulus is {@code r = x - (floorDiv(x, y) * y)}, + * has the same sign as the divisor {@code y} or is zero, and * is in the range of {@code -abs(y) < r < +abs(y)}. + * *
* The relationship between {@code floorDiv} and {@code floorMod} is such that: *
* See {@link Math#floorMod(int, int) Math.floorMod} for examples and @@ -1150,14 +1151,14 @@ public final class StrictMath { /** * Returns the floor modulus of the {@code long} and {@code int} arguments. *
- * The floor modulus is {@code x - (floorDiv(x, y) * y)}, - * has the same sign as the divisor {@code y}, and + * The floor modulus is {@code r = x - (floorDiv(x, y) * y)}, + * has the same sign as the divisor {@code y} or is zero, and * is in the range of {@code -abs(y) < r < +abs(y)}. * *
* The relationship between {@code floorDiv} and {@code floorMod} is such that: *
* See {@link Math#floorMod(int, int) Math.floorMod} for examples and @@ -1178,13 +1179,14 @@ public final class StrictMath { /** * Returns the floor modulus of the {@code long} arguments. *
- * The floor modulus is {@code x - (floorDiv(x, y) * y)}, - * has the same sign as the divisor {@code y}, and + * The floor modulus is {@code r = x - (floorDiv(x, y) * y)}, + * has the same sign as the divisor {@code y} or is zero, and * is in the range of {@code -abs(y) < r < +abs(y)}. + * *
* The relationship between {@code floorDiv} and {@code floorMod} is such that: *
* See {@link Math#floorMod(int, int) Math.floorMod} for examples and