小编Jee*_*van的帖子

Math.Round为十进制

我正在运行此代码:

decimal d = 1.45M;

Console.WriteLine((System.Math.Round(d,0,MidpointRounding.AwayFromZero).ToString()));
Run Code Online (Sandbox Code Playgroud)

在这里我期望输出为2,因为当舍入到第一个小数位时,1.45将是1.5,当下一个舍入到0小数位时应该是2.

但是,我得到的答案是1.

我的假设是否正确?如果是这样,这是Math.Round的错误吗?

c# rounding

3
推荐指数
1
解决办法
6299
查看次数

标签 统计

c# ×1

rounding ×1