How do I round a positive float up the next integer?
Use the Ceil
function from the Math
unit. From the documentation:
Rounds variables up toward positive infinity.
Call Ceil (as in ceiling) to obtain the lowest integer greater than or equal to X. The absolute value of X must be less than MaxInt. For example:
- Ceil(-2.8) = -2
- Ceil(2.8) = 3
- Ceil(-1.0) = -1
I cannot tell whether or not the behaviour of Ceil
meets your expectations for negative input values, because you did not specify what to do there. However, if Ceil
does not meet your expectations, it is easy enough to write a function to meet your needs, by combining Abs()
and Ceil()