且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java剩余整数除法?

更新时间:2023-12-04 08:19:46

如果您正在寻找数学模运算,可以使用

If you are looking for the mathematical modulo operation you could use

int x = -22;
int y = 24;
System.out.println(Math.floorMod(x, y));

如果您对数学模数不感兴趣(仅余数),则可以使用

If you are not interested in the mathematical modulo (just the remainder) then you could use

int x = -22;
int y = 24;
System.out.println(x%y);