@@ -1247,7 +1247,7 @@ public static long unsignedMultiplyHigh(long x, long y) {
12471247 /**
12481248 * Returns the largest (closest to positive infinity)
12491249 * {@code int} value that is less than or equal to the algebraic quotient.
1250- * There is one special case, if the dividend is the
1250+ * There is one special case: if the dividend is
12511251 * {@linkplain Integer#MIN_VALUE Integer.MIN_VALUE} and the divisor is {@code -1},
12521252 * then integer overflow occurs and
12531253 * the result is equal to {@code Integer.MIN_VALUE}.
@@ -1256,14 +1256,16 @@ public static long unsignedMultiplyHigh(long x, long y) {
12561256 * (truncation). This operation instead acts under the round toward
12571257 * negative infinity (floor) rounding mode.
12581258 * The floor rounding mode gives different results from truncation
1259- * when the exact result is negative.
1259+ * when the exact quotient is not an integer and is negative.
12601260 * <ul>
12611261 * <li>If the signs of the arguments are the same, the results of
12621262 * {@code floorDiv} and the {@code /} operator are the same. <br>
12631263 * For example, {@code floorDiv(4, 3) == 1} and {@code (4 / 3) == 1}.</li>
1264- * <li>If the signs of the arguments are different, the quotient is negative and
1265- * {@code floorDiv} returns the integer less than or equal to the quotient
1266- * and the {@code /} operator returns the integer closest to zero.<br>
1264+ * <li>If the signs of the arguments are different, {@code floorDiv}
1265+ * returns the largest integer less than or equal to the quotient
1266+ * while the {@code /} operator returns the smallest integer greater
1267+ * than or equal to the quotient.
1268+ * They differ if and only if the quotient is not an integer.<br>
12671269 * For example, {@code floorDiv(-4, 3) == -2},
12681270 * whereas {@code (-4 / 3) == -1}.
12691271 * </li>
@@ -1290,7 +1292,7 @@ public static int floorDiv(int x, int y) {
12901292 /**
12911293 * Returns the largest (closest to positive infinity)
12921294 * {@code long} value that is less than or equal to the algebraic quotient.
1293- * There is one special case, if the dividend is the
1295+ * There is one special case: if the dividend is
12941296 * {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1},
12951297 * then integer overflow occurs and
12961298 * the result is equal to {@code Long.MIN_VALUE}.
@@ -1299,7 +1301,7 @@ public static int floorDiv(int x, int y) {
12991301 * (truncation). This operation instead acts under the round toward
13001302 * negative infinity (floor) rounding mode.
13011303 * The floor rounding mode gives different results from truncation
1302- * when the exact result is negative.
1304+ * when the exact result is not an integer and is negative.
13031305 * <p>
13041306 * For examples, see {@link #floorDiv(int, int)}.
13051307 *
@@ -1319,7 +1321,7 @@ public static long floorDiv(long x, int y) {
13191321 /**
13201322 * Returns the largest (closest to positive infinity)
13211323 * {@code long} value that is less than or equal to the algebraic quotient.
1322- * There is one special case, if the dividend is the
1324+ * There is one special case: if the dividend is
13231325 * {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1},
13241326 * then integer overflow occurs and
13251327 * the result is equal to {@code Long.MIN_VALUE}.
@@ -1328,7 +1330,7 @@ public static long floorDiv(long x, int y) {
13281330 * (truncation). This operation instead acts under the round toward
13291331 * negative infinity (floor) rounding mode.
13301332 * The floor rounding mode gives different results from truncation
1331- * when the exact result is negative.
1333+ * when the exact result is not an integer and is negative.
13321334 * <p>
13331335 * For examples, see {@link #floorDiv(int, int)}.
13341336 *
@@ -1353,40 +1355,35 @@ public static long floorDiv(long x, long y) {
13531355 /**
13541356 * Returns the floor modulus of the {@code int} arguments.
13551357 * <p>
1356- * The floor modulus is {@code x - (floorDiv(x, y) * y)},
1357- * has the same sign as the divisor {@code y}, and
1358+ * The floor modulus is {@code r = x - (floorDiv(x, y) * y)},
1359+ * has the same sign as the divisor {@code y} or is zero , and
13581360 * is in the range of {@code -abs(y) < r < +abs(y)}.
13591361 *
13601362 * <p>
13611363 * The relationship between {@code floorDiv} and {@code floorMod} is such that:
13621364 * <ul>
1363- * <li>{@code floorDiv(x, y) * y + floorMod(x, y) == x}
1365+ * <li>{@code floorDiv(x, y) * y + floorMod(x, y) == x}</li>
13641366 * </ul>
13651367 * <p>
1366- * The difference in values between {@code floorMod} and
1367- * the {@code %} operator is due to the difference between
1368- * {@code floorDiv} that returns the integer less than or equal to the quotient
1369- * and the {@code /} operator that returns the integer closest to zero.
1368+ * The difference in values between {@code floorMod} and the {@code %} operator
1369+ * is due to the difference between {@code floorDiv} and the {@code /}
1370+ * operator, as detailed in {@linkplain #floorDiv(int, int)}.
13701371 * <p>
13711372 * Examples:
13721373 * <ul>
1373- * <li>If the signs of the arguments are the same, the results
1374- * of {@code floorMod} and the {@code %} operator are the same.<br>
1374+ * <li>Regardless of the signs of the arguments, {@code floorMod}(x, y)
1375+ * is zero exactly when {@code x % y} is zero as well.</li>
1376+ * <li>If neither of {@code floorMod}(x, y) or {@code x % y} is zero,
1377+ * their results differ exactly when the signs of the arguments differ.<br>
13751378 * <ul>
13761379 * <li>{@code floorMod(+4, +3) == +1}; and {@code (+4 % +3) == +1}</li>
13771380 * <li>{@code floorMod(-4, -3) == -1}; and {@code (-4 % -3) == -1}</li>
1378- * </ul>
1379- * <li>If the signs of the arguments are different, the results
1380- * differ from the {@code %} operator.<br>
1381- * <ul>
13821381 * <li>{@code floorMod(+4, -3) == -2}; and {@code (+4 % -3) == +1}</li>
13831382 * <li>{@code floorMod(-4, +3) == +2}; and {@code (-4 % +3) == -1}</li>
13841383 * </ul>
13851384 * </li>
13861385 * </ul>
13871386 * <p>
1388- * If the signs of arguments are unknown and a positive modulus
1389- * is needed it can be computed as {@code (floorMod(x, y) + abs(y)) % abs(y)}.
13901387 *
13911388 * @param x the dividend
13921389 * @param y the divisor
@@ -1407,14 +1404,14 @@ public static int floorMod(int x, int y) {
14071404 /**
14081405 * Returns the floor modulus of the {@code long} and {@code int} arguments.
14091406 * <p>
1410- * The floor modulus is {@code x - (floorDiv(x, y) * y)},
1411- * has the same sign as the divisor {@code y}, and
1407+ * The floor modulus is {@code r = x - (floorDiv(x, y) * y)},
1408+ * has the same sign as the divisor {@code y} or is zero , and
14121409 * is in the range of {@code -abs(y) < r < +abs(y)}.
14131410 *
14141411 * <p>
14151412 * The relationship between {@code floorDiv} and {@code floorMod} is such that:
14161413 * <ul>
1417- * <li>{@code floorDiv(x, y) * y + floorMod(x, y) == x}
1414+ * <li>{@code floorDiv(x, y) * y + floorMod(x, y) == x}</li>
14181415 * </ul>
14191416 * <p>
14201417 * For examples, see {@link #floorMod(int, int)}.
@@ -1434,14 +1431,14 @@ public static int floorMod(long x, int y) {
14341431 /**
14351432 * Returns the floor modulus of the {@code long} arguments.
14361433 * <p>
1437- * The floor modulus is {@code x - (floorDiv(x, y) * y)},
1438- * has the same sign as the divisor {@code y}, and
1434+ * The floor modulus is {@code r = x - (floorDiv(x, y) * y)},
1435+ * has the same sign as the divisor {@code y} or is zero , and
14391436 * is in the range of {@code -abs(y) < r < +abs(y)}.
14401437 *
14411438 * <p>
14421439 * The relationship between {@code floorDiv} and {@code floorMod} is such that:
14431440 * <ul>
1444- * <li>{@code floorDiv(x, y) * y + floorMod(x, y) == x}
1441+ * <li>{@code floorDiv(x, y) * y + floorMod(x, y) == x}</li>
14451442 * </ul>
14461443 * <p>
14471444 * For examples, see {@link #floorMod(int, int)}.
0 commit comments