简体   繁体   English

使用Math.Round(ReportItems!category.Value,MidpointRounding.AwayFromZero)返回不正确的值

[英]Using Math.Round(ReportItems!category.Value,MidpointRounding.AwayFromZero) returns incorrect value

I am using 我在用

=Math.Round(ReportItems!category.Value,MidpointRounding.AwayFromZero) 

in a tablix row, which results incorrect value. 在tablix行中,这将导致错误的值。

5.48 is rounding to 5 5.48舍入到5

Instead, I would like to see 5.48 as 6 . 相反,我想将5.48视为6

您要的不是四舍五入 ,而是正数为Ceiling ,负数为Floor

MidpointRounding.AwayFromZero Is a way of defining how the midpoint value is handled. MidpointRounding.AwayFromZero是一种定义如何处理中点值的方法。 The midpoint is X.5 . 中点是X.5 So, 4.5 is rounded to 5 , rather than 4 , which is what would happen in the case of MidpointRounding.ToEven . 因此,将4.5舍入为5而不是4 ,这是在MidpointRounding.ToEven情况下会发生的情况。 Round is completely correct. Round是完全正确的。

If you want to write a function that rounds all non-integer values to the next highest integer then that operation is Math.Ceiling , not Round . 如果要编写一个将所有非整数值Math.Ceiling入到下一个最大整数的函数,则该操作为Math.Ceiling ,而不是Round

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM