简单的问题,我认为,我是一个有点不确定,为什么分成fractors在C#
decimal currentPercentage = 0;
currentPercentage = currentPercentage*((decimal)1/(decimal)daysPerYear--);//or
currentPercentage *= ((decimal)1/(decimal)daysPerYear--);
将返回0每次但
(decimal)1/(decimal)daysPerYear--;
将返回我后的位数。我在这里错过了什么?
什么是fractor? – Robaticus 2010-06-13 14:57:09
之前的海报都解决了你的问题,但我无法抗拒提供一些个人建议:考虑查看你的类型,所以你不必一直抛出所有的东西。对于文字1,使用1M使其成为小数。另外,在计算中使用递减运算符( - )相当容易出错。您的代码可能会有益于您在单独的声明中递减。 – Jakob 2010-06-13 15:02:34