Difference between decimal.Round

What’s the difference?

decimal.Round(xx, decimalPos, MidpointRounding.ToEven);


decimal.Round(xx, decimalPos, MidpointRounding.AwayFromZero);

AwayFromZero, is the commonly used rounding.

ToEven, is more special, called rounding to nearest or rounding to 50%

        22.333        to         22.33
        22.335        to         22.34
        22.325        to         22.32
        22.336        to         22.34
        22.326        to         22.33

The case of 5 in the back is special. If the front is an odd number, it will go up. Otherwise, it will be cut off. In financial settlement, this method is often used to balance the profit and loss of both parties.

Leave a Reply

Your email address will not be published. Required fields are marked *