ceil

ceil(x, out=None, **kwargs)

Return the ceiling of the input, element-wise. The ceil of the ndarray x is the smallest integer i, such that i >= x. It is often denoted as \(\lceil x \rceil\).

Parameters:
x : ndarray or scalar

Input array.

out : ndarray or None

A location into which the result is stored. If provided, it must have a shape that the inputs fill into. If not provided or None, a freshly-allocated array is returned. The dtype of the output and input must be the same.

Returns:
y : ndarray or scalar

The ceiling of each element in x, with float dtype. This is a scalar if x is a scalar.

Examples

>>> a = np.array([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0])
>>> np.ceil(a)
array([-1., -1., -0.,  1.,  2.,  2.,  2.])
>>> # if you use parameter out, x and out must be ndarray.
>>> a = np.array(1)
>>> np.ceil(np.array(3.5), a)
array(4.)
>>> a
array(4.)