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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 get a double result. Since double is greater that int and long, int and long will be turned into double in(double)/(long)and(int)/(double)