Possible Duplicate:
Divide problem
Why does c# show the output of this code as 0??
MessageBox.Show((5/6).ToString);
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.
5/6is basically integral division, which turns out to be0. The type of both operands isint.I think what you want is :
5.0/6.0.In fact,
5.0/6.0,5/6.0,5.0/6, all would give same result. That is, as long as, one operand isdouble, it would be a double division, and the type of the result would bedoubleas well.