public class test {
public static void main(String[] args) {
int total = 2;
int rn = 1;
double rnp = (rn / total) * 100;
System.out.println(rnp);
}
}
为什么打印0.0而不是50.0?
https://www.google.com/search?q=100*(1%2F2)&aq=f&oq=100*(1%2F2)
最佳答案
除法发生在没有分数概念的整数空间中,您需要类似
double rnp = (rn / (double) total) * 100
关于java - Java算术部门,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15649057/