+ 3
Output c#
I saw this code on c# interview questions. I thought the output will be 7 and 12 but the truth is the output will be 6 and 12. Why is that? public class Program { public static void Main(string[] args) { Console.WriteLine(Math.Round(6.5)); Console.WriteLine(Math.Round(11.5)); } }
1 Respuesta
+ 4
Math.round (c#) runs on something called bankers rounding:
"The integer nearest a. If the fractional component of a is halfway between two integers, one of which is even and the other odd, then the even number is returned."