Unexpected result in long/int division
问题 I have values like this: long millis = 11400000; int consta = 86400000; double res = millis/consta; The question is: why res equals 0.0 (instead of ca. 0.131944 )? It's stored in double so there should be no rounding right? 回答1: When you are using a binary operator, both arguments should be of a same type and the result will be in their type too. When you want to divide (int)/(long) it turns into (long)/(long) and the result is (long) . you shouldmake it (double)/(long) or (int)/(double) to