摘要:
在c#中除法默认不保留小数点,decimal result = 100 / 1000; // result = 0;需要保留小数点,可以如下decimal result = 100m / 1000;m代表decimal.如果是变量要如何处理呢?这是需要用到Math.Round()int x= 120;int y= 100000;decimal result = (decimal)x / y; // (decimal)x/ y 表示把 x 转换成decimal再做除法运算,int 除 int 是会丢失小数点的。不过这样的小数点后面的数太多了,需要处理下,这时候需要Math.Round()deci 阅读全文
posted @ 2012-04-18 15:34
海乐学习
阅读(1991)
评论(0)
推荐(0)

浙公网安备 33010602011771号