Math.Round returning a rounded up for odd values but rounds down for even

后端 未结 4 788
情深已故
情深已故 2021-01-13 12:34

I am trying to found a float using math round I found the following

0.5 --> 0
1.5 --> 2
2.5 --> 2
3.5 --> 4

and so on. I believ

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-13 13:25

    This is known as bankers rounding (round to even). You can read more about it here. This is a .NET Framework feature and is working as designed.

提交回复
热议问题