问题是这样:
现在 parame[5].Value 是从数据库返回的output参数带有两位小数的值,如:46.28
我这如果以如下方式接受的话,得到的money1是46,是四舍五入后的,怎么样得到确切的46.28呢??
decimal money1 = (decimal)parame[5].Value;
现在 parame[5].Value 是从数据库返回的output参数带有两位小数的值,如:46.28
我这如果以如下方式接受的话,得到的money1是46,是四舍五入后的,怎么样得到确切的46.28呢??
decimal money1 = (decimal)parame[5].Value;
double.Parse(String.Format("{0:N}",d)); double x = double.Parse("");
double y = x % 0.01;
double z = x - y;
decimal a = 46.28111;
string result=a.ToString("#0.00");
输出result=46.28
Console.WriteLine(d.ToString("#0.00"));
tosting()方法里有很多转换格式的。
在这句话时后面的两位就已经没有了
3楼的double d=45.123456;
MessageBox.Show(double.Parse(String.Format("{0:N}", d)).ToString());
http://www.cnblogs.com/terryding/archive/2009/03/26/1060938.html