关于java的取整/和取余%

double a=10;
double b=5;
double i = (a - b)/2;
System.out.println(i);

输出:2.5


int a=10;
int b=5;
double i =(double ) (a - b)/2;
System.out.println(i);

输出:2.5

你可能感兴趣的:(Java,java取整)