//Jisuan.javapublic class Jisuan{
public static void main(String[] args){
int a=-8%3; //将这里改成 int a=-8%-3,输出结果还是-2
System.out.println(a);
}
}
谁能帮忙解释一下??
public static void main(String[] args){
int a=-8%3; //将这里改成 int a=-8%-3,输出结果还是-2
System.out.println(a);
}
}
谁能帮忙解释一下??
5%(-3) produces 2 (note that 5/(-3) produces -1)
(-5)%3 produces -2 (note that (-5)/3 produces -1)
(-5)%(-3) produces -2 (note that (-5)/(-3) produces 1)