Java之整数运算

  Java的整数运算遵循四则运算规则,可以使用任意嵌套的小括号。四则运算规则和初等数学一致。例如:

public class Main {
    public static void main(String[] args) {
    	int i=(100+200)*(99-88);//3300
    	int n=7*(5+(i-9));//23072
    	System.out.println(i);
    	System.out.println(n);
    }
}

   输出

3300
23072

   整数运算的数值不但是精确的,而且整数运算永远是精确的,即使是出发,因为两个整数相除只得到结果的整数部分,不进行四舍五入

猜你喜欢

转载自www.cnblogs.com/minseo/p/11727398.html