Possible Duplicate:
1/252 = 0 in c#?
hi i have a problem with c#, i want to calculate some things. but when i get a expression like:
decimal test = 3 / 2;
c# says test=1 and not 1.5
how to solve this?
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.
You’re using integer arithmetic. If you don’t want to do that, make one or both of the operands floating point values, e.g.
or
(Only one of the operands has to be a non-integral type, but I believe it’s clearer if you can easily make both of them the same.)