Today, the customer ran over and told me that the price calculated in our program was incorrect. I checked and found that the price was converted, and the result was probably a large number of decimal places, only two prices can be printed on the document, So math is called for the price. the round (price, 2) function is rounding.
The unit price is 1.805, And the return value of the function math. Round (1.085, 2) is 1.80. According to the rounding principle, the result should be 1.81.
After some Google attacks, we found Microsoft was right. We were wrong. :(
It turns out that there is also an international practice, called odd-in-even homes. This means that when the first digit in the Round-off position is an odd number, it will go in. If it is an even number, it will go in, this is also the principle of fairness.
However, in international practice, many enterprises in China do not work. To cope with their requirements, we can use math. Round (price, 2, midpointrounding. awayfromzero.
Math. Round rounded