Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 4.0 我如何将双倍金额取整?_C# 4.0_Math_Rounding - Fatal编程技术网

C# 4.0 我如何将双倍金额取整?

C# 4.0 我如何将双倍金额取整?,c#-4.0,math,rounding,C# 4.0,Math,Rounding,我如何舍入货币价值 我基本上有以下代码,但它并没有真正做到我希望它做的事情 double amount = 1.236356789; Math.Round(amount, 2, MidpointRounding.ToEven); 我希望输出为1.23。Math.Truncate()或Math.Floor()?我仍然希望保留逗号后的数字,但要向下舍入。基本上我和钱打交道不确定我是否看到了你的问题-你想删除一些数字,但仍然保留这些数字?你说的是打印/显示格式吗?double dispaum=Mat

我如何舍入货币价值

我基本上有以下代码,但它并没有真正做到我希望它做的事情

double amount = 1.236356789;
Math.Round(amount, 2, MidpointRounding.ToEven);

我希望输出为1.23。

Math.Truncate()或Math.Floor()?我仍然希望保留逗号后的数字,但要向下舍入。基本上我和钱打交道不确定我是否看到了你的问题-你想删除一些数字,但仍然保留这些数字?你说的是打印/显示格式吗?double dispaum=Math.Truncate(amount*100.0)/100.0;然后使用dispAmount.ToString(“0.00”)