Math.Ceiling returns double because double may store much bigger numbers. However if i'm sure that int type is capable to store the result how should I convert? Is it safe to cast (int) Math.Ceiling(... ?
Math.Ceiling
double
int
(int) Math.Ceiling(...
If you are sure that you do not cross the capacity of int, it should be perfectly safe to do
int myInt = (int)Math.Ceiling(...);
If you are not sure about the bound, you could go with long instead of int.
long
2.1m questions
2.1m answers
60 comments
57.0k users