8271601: Math.floorMod(int, int) and Math.floorMod(long, long) differ in their logic

Reviewed-by: bpb
This commit is contained in:
Raffaello Giulietti 2021-08-10 17:16:17 +00:00 committed by Brian Burkhalter
parent 57ae9fbe77
commit 66d1faa784

View File

@ -1394,7 +1394,7 @@ public final class Math {
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) {
if ((x ^ y) < 0 && mod != 0) {
mod += y;
}
return mod;