+ 1

Anyone know why?

Console.WriteLine(Math.Round(5.5));// 6 But Console.WriteLine(Math.Round(6.5));// 6

29th Nov 2019, 2:09 PM
Opponent Cloud
Opponent Cloud - avatar
1 Resposta
+ 3
I am not sure why you getting 5 and 6 as output. In round function if floating point value is greater than .5 then it will return next higher integer, but if it is less than .5 then it will return nearest lower integer. When it is exactly .5, it will always give next integer
29th Nov 2019, 2:12 PM
Raj Chhatrala
Raj Chhatrala - avatar