在c#中int与int的除法默认不保留小数点,
float result = 1010 / 100; // result = 10;
需要保留小数点,可以如下
float result = 1010f或者(float)1010F / 100;
如果需要限定小数点的位数,则可以使用Math.Round():
float result = Math.Round((float)x/ y,2); 后面的2表示保留小数点后2位小数