Possible Duplicate:
Division returns zero
Say you have the code below.
double d=16/60; //I got d is 0.0 , but I expected d could be 0.27.
How to make it ?thanks.
Edit for the Best Answer 🙂
double d=16/60f;
d= Math.Round(d, 2); //result being 0.27
This is due to integer division.
At least one of the operands needs to be a floating point type (
floatordouble).