CEIL function

Purpose

Convert a floating-point variable or expression into an integer-class value, by returning the smallest integer value that is greater than or equal to its argument.

Syntax

intvar = CEIL(numeric_expression)

Remarks

The CEIL function rounds upward, returning the smallest integer value that is greater than or equal to numeric_expression.  For example, y = CEIL(1.5) places the value 2 into y.

See also

CINT, FIX, FRAC, INT, ROUND

Example

' Display the ceiling for a series of values
FOR W! = -1.5! TO 1.5! STEP 0.5!
  x$ = "CEIL" + FORMAT$(W!, "* 0.00") + _
    " =" + FORMAT$(CEIL(W!), "* 0.00")
NEXT W!

Result

CEIL -1.50 = -1.00
CEIL -1.00 = -1.00
CEIL -0.50 =  0.00
CEIL  0.00 =  0.00
CEIL  0.50 =  1.00
CEIL  1.00 =  1.00
CEIL  1.50 =  2.00