[ Arithmetic | Reference Manual | Alphabetic Index ]

ceiling(+Number, -Result)

Unifies Result with the least integral value that is greater than or equal to Number and of the same numeric type as Number.
A number.
A variable or number.


This predicate is used by the ECLiPSe compiler to expand evaluable arithmetic expressions. So the call to ceiling(Number, Result) is equivalent to
    Result is ceiling(Number)
which should be preferred.

This operation works on all numeric types. The result value is the smallest integral value that is greater than Number (rounding up towards positive infinity).

The result type is the same as the argument type. To convert the type to integer, use integer/2.

In coroutining mode, if Number is uninstantiated, the call to ceiling/2 is delayed until this variable is instantiated.

Modes and Determinism


(4) instantiation fault
Number is not instantiated (non-coroutining mode only).
(24) number expected
Number is not of a numeric type.


      ceiling(1.8, 2.0).
      ceiling(-1.8, -1.0).
      ceiling(5, 5).
      ceiling(-6.4, Result).      (gives Result = -6.0)
      ceiling(0.0, 1.0).
      ceiling(0.5, 0).
      ceiling(1, r).
      ceiling(A, 6.0).                   (Error 4).
      ceiling(4 + 2.3, 6.0).             (Error 24).

See Also

is / 2, floor / 2, round / 2, truncate / 2, integer / 2