In C# the method Math.Ceiling
returns a double
value. Why does it not return int
?
Math.Ceiling
can return either a double
or a decimal
, depending on the type passed in. In other words, the output type of the method matches the input type (quite sensibly).
They could have added a third overload that takes an int
and returns an int
, but there wouldn't have been much point to this - the function would always just return its input.
You seem to be assuming that the purpose of Math.Ceiling
is to cast a floating-point value to an integer, but that's usually not how it's used.