public class test {
public static void main(String[] args) {
int total = 2;
int rn = 1;
double rnp = (rn/total) * 100;
System.out.println(rnp);
}
}
50.0 대신 0.0을 인쇄하는 이유는 무엇입니까? 분할 분수없이 개념과 정수 공간에서 발생Java 산술 부서
https://www.google.com/search?q=100*(1%2F2)&aq=f&oq=100*(1%2F2)
왜냐하면 '1/2'는 정수 나누기에서 0이기 때문입니다. – corsiKa
가능한 복제본은 [Java 부문에서 항상 0이됩니다.] (http://stackoverflow.com/questions/10455677/division-in-java-always-results-in-zero-0) –
수도 있습니다. 대답을 고려하면 [C 프로그래밍 부문] (http://stackoverflow.com/questions/8906722/c-programming-division)의 중복을 고려하십시오. – corsiKa