Processing data accuracy issues

       The accuracy of this data is a small problem, there is a special function in .net for processing, System.Decimal.Round, but you know System.Decimal.Round (a, 2), System.Decimal.Round (a , 2) and

Difference System.Decimal.Round (a, 2, MidpointRounding.AwayFromZero) these two functions do, as well as in the SQLServer database Round (a, 2) the value is kind of how it?

       When using System.Decimal, but now there is the use of international round-6 into 4 Under normal circumstances, we use in everyday life is round 4 to 5 into the calculation of the 5 pairs of algorithms that take a decimal in C # code .Round (a, 2) the method, if access is System.Decimal.Round (a, 2, MidpointRounding.AwayFromZero) this method is used in our daily use of the 4 round 5. But generally we use the Round (a, 2) This method is taking 4 round 5 of the algorithm in SQL Server. However, SQL Server does not provide ready-made to achieve the dual 4 5 6 homes, you need to write your own functions to achieve. It is very easy in the code 6 using the 5 pairs round 4, used in the database 5 is rounded into 4. If the query of financial statements and documents involved, it is likely there will be error accuracy.

       General Finance appeared on the deviation, even if it is a penny is not allowed, so this question we must consider the design of the system at the beginning of consistency, but many systems may not have considered before. Currently we are implementing a project we found the current system there has been such a problem. So the question the accuracy can not be ignored.

     

Reproduced in: https: //www.cnblogs.com/kevinGao/archive/2013/01/09/2922935.html

Guess you like

Origin blog.csdn.net/weixin_33958366/article/details/93356904