double x = Math.Round(1.5);
double z = Math.Round(2.5);
Console.WriteLine(x);
Console.WriteLine(z);
if you run this code then you will see that the answer of x and z is 2 because "roundof()" methos always give us answer in even number.
double x = Math.Round(1.5);
double z = Math.Round(3.5);
Console.WriteLine(x);
Console.WriteLine(z);
if you run this code then you will see that the answer of x is 2 and answer of z is 4 because "roundof()" methos always give us answer in even number.
Thats why we prefer to use "Math.Floor()" and "Math.Ceiling()" function rather then "roundof()" method.
No comments:
Post a Comment