< prev index next >

src/java.base/share/classes/java/lang/Math.java

Print this page

        

*** 1272,1287 **** * @throws ArithmeticException if the divisor {@code y} is zero * @see #floorDiv(int, int) * @since 1.8 */ public static int floorMod(int x, int y) { ! int mod = x % y; ! // if the signs are different and modulo not zero, adjust result ! if ((mod ^ y) < 0 && mod != 0) { ! mod += y; ! } ! return mod; } /** * Returns the floor modulus of the {@code long} and {@code int} arguments. * <p> --- 1272,1282 ---- * @throws ArithmeticException if the divisor {@code y} is zero * @see #floorDiv(int, int) * @since 1.8 */ public static int floorMod(int x, int y) { ! return x - floorDiv(x, y) * y; } /** * Returns the floor modulus of the {@code long} and {@code int} arguments. * <p>
*** 1304,1314 **** * @see #floorDiv(long, int) * @since 9 */ public static int floorMod(long x, int y) { // Result cannot overflow the range of int. ! return (int)floorMod(x, (long)y); } /** * Returns the floor modulus of the {@code long} arguments. * <p> --- 1299,1309 ---- * @see #floorDiv(long, int) * @since 9 */ public static int floorMod(long x, int y) { // Result cannot overflow the range of int. ! return (int)(x - floorDiv(x, y) * y); } /** * Returns the floor modulus of the {@code long} arguments. * <p>
*** 1330,1345 **** * @throws ArithmeticException if the divisor {@code y} is zero * @see #floorDiv(long, long) * @since 1.8 */ public static long floorMod(long x, long y) { ! long mod = x % y; ! // if the signs are different and modulo not zero, adjust result ! if ((x ^ y) < 0 && mod != 0) { ! mod += y; ! } ! return mod; } /** * Returns the absolute value of an {@code int} value. * If the argument is not negative, the argument is returned. --- 1325,1335 ---- * @throws ArithmeticException if the divisor {@code y} is zero * @see #floorDiv(long, long) * @since 1.8 */ public static long floorMod(long x, long y) { ! return x - floorDiv(x, y) * y; } /** * Returns the absolute value of an {@code int} value. * If the argument is not negative, the argument is returned.
< prev index next >