ceil - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

# Online Help

###### All Products    Maple    MapleSim

trunc

truncate a number to the next nearest integer towards 0

round

round a number to the nearest integer

frac

fractional part of a number

floor

greatest integer less than or equal to a number

ceil

smallest integer greater than or equal to a number

 Calling Sequence trunc(n, x) round(n, x) frac(n, x) floor(n, x) ceil(n, x)

Parameters

 n - (optional) any expression, assumed to be a non-negative integer x - any expression

Description

 • These functions compute integer or fractional parts of numbers.  For real arguments x:
 For $0\le x$, trunc(x) is the greatest integer less than or equal to x.  For $x<0$, trunc(x) = -trunc(-x).
 round(x) rounds x to the nearest integer. In case of a tie (at half-integers), it rounds away from 0.
 frac(x) is the fractional part of x, that is, frac(x) = x - trunc(x).
 floor(x) (floor) is the greatest integer less than or equal to x.
 ceil(x) (ceiling) is the smallest integer greater than or equal to x.
 • For complex arguments x:
 trunc(x) = trunc($\mathrm{\Re }\left(x\right)$) + I*trunc($\mathrm{\Im }\left(x\right)$)
 round(x) = round($\mathrm{\Re }\left(x\right)$) + I*round($\mathrm{\Im }\left(x\right)$)
 frac(x) = frac($\mathrm{\Re }\left(x\right)$) + I*frac($\mathrm{\Im }\left(x\right)$)
 For floor(x), let $a=\mathrm{\Re }\left(x\right)-⌊\mathrm{\Re }\left(x\right)⌋$ and let $b=\mathrm{\Im }\left(x\right)-⌊\mathrm{\Im }\left(x\right)⌋$.  Then floor(x) = floor($\mathrm{\Re }\left(x\right)$) + I*floor($\mathrm{\Im }\left(x\right)$) + X, where

$X=\left\{\begin{array}{cc}0& a+b<1\\ 1& 1\le a+b\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{and}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}b\le a\\ I& 1\le a+b\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{and}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}a

 ceil(x) = -floor(-x)
 • For all functions, the two-argument case indicates the nth derivative of the function at x.  Except for frac, these derivatives are 0 wherever they are defined.  For frac, the first derivative is 1 wherever it is defined.
 • If x is a constant, these functions will use evalr() to try to cautiously evaluate x to a floating point number and then apply themselves to the result.  This computation is performed initially at the current setting of Digits, and then if necessary a limited number of times more at higher settings.  If evalr() continues to return a result which is ambiguous with respect to the function being applied, the original function will return unevaluated. In this case, increasing Digits before calling the function may still help in rare cases.
 • In all other cases, these functions return unevaluated.

Thread Safety

 • The trunc command is thread-safe as of Maple 15.
 • For more information on thread safety, see index/threadsafe.

Examples

Truncate a number to the nearest integer towards 0.

 > $\mathrm{trunc}\left(7\right)$
 ${7}$ (1)
 > $\mathrm{trunc}\left(\frac{8}{3}\right)$
 ${2}$ (2)
 > $\mathrm{trunc}\left(-2.4\right)$
 ${-2}$ (3)
 > $\mathrm{trunc}\left(\mathrm{\pi }\right)$
 ${3}$ (4)
 > $\mathrm{trunc}\left(3.5+4.2I\right)$
 ${3}{+}{4}{}{I}$ (5)

Round a number to the nearest integer.

 > $\mathrm{round}\left(7\right)$
 ${7}$ (6)
 > $\mathrm{round}\left(\frac{8}{3}\right)$
 ${3}$ (7)
 > $\mathrm{round}\left(-2.4\right)$
 ${-2}$ (8)
 > $\mathrm{round}\left(\mathrm{\pi }\right)$
 ${3}$ (9)
 > $\mathrm{round}\left(3.5+4.2I\right)$
 ${4}{+}{4}{}{I}$ (10)

Fractional part of a number.

 > $\mathrm{frac}\left(7\right)$
 ${0}$ (11)
 > $\mathrm{frac}\left(\frac{8}{3}\right)$
 $\frac{{2}}{{3}}$ (12)
 > $\mathrm{frac}\left(-2.4\right)$
 ${-0.4}$ (13)
 > $\mathrm{frac}\left(\mathrm{\pi }\right)$
 ${\mathrm{\pi }}{-}{3}$ (14)
 > $\mathrm{frac}\left(3.5+4.2I\right)$
 ${0.5}{+}{0.2}{}{I}$ (15)

Greatest integer less than or equal to a number.

 > $\mathrm{floor}\left(7\right)$
 ${7}$ (16)
 > $\mathrm{floor}\left(\frac{8}{3}\right)$
 ${2}$ (17)
 > $\mathrm{floor}\left(-2.4\right)$
 ${-3}$ (18)
 > $\mathrm{floor}\left(\mathrm{\pi }\right)$
 ${3}$ (19)
 > $\mathrm{floor}\left(3.5+4.2I\right)$
 ${3}{+}{4}{}{I}$ (20)

Smallest integer greater than or equal to a number.

 > $\mathrm{ceil}\left(7\right)$
 ${7}$ (21)
 > $\mathrm{ceil}\left(\frac{8}{3}\right)$
 ${3}$ (22)
 > $\mathrm{ceil}\left(-2.4\right)$
 ${-2}$ (23)
 > $\mathrm{ceil}\left(\mathrm{\pi }\right)$
 ${4}$ (24)
 > $\mathrm{ceil}\left(3.5+4.2I\right)$
 ${4}{+}{4}{}{I}$ (25)

More advanced operations.

 > $\mathrm{ceil}\left(\mathrm{exp}\left(3\right)\right)$
 ${21}$ (26)
 > $\mathrm{trunc}\left(\mathrm{diff}\left(76.8x,x\right)\right)$
 ${76}$ (27)
 > $\mathrm{round}\left(\mathrm{eval}\left({x}^{2}+5x-9,x=2.1\right)\right)$
 ${6}$ (28)

The functions can be differentiated.

 > $\mathrm{diff}\left(\mathrm{trunc}\left(x\right),x\right)$
 ${\mathrm{trunc}}{}\left({1}{,}{x}\right)$ (29)
 > $\mathrm{diff}\left(\mathrm{round}\left(x\right),x\right)$
 $⌊{x}⌉{\prime }$ (30)
 > $\mathrm{diff}\left(\mathrm{frac}\left(x\right),x\right)$
 ${1}{-}{\mathrm{trunc}}{}\left({1}{,}{x}\right)$ (31)
 > $\mathrm{diff}\left(\mathrm{floor}\left(x\right),x\right)$
 ${⌊{x}⌋}^{\left({1}\right)}$ (32)
 > $\mathrm{diff}\left(\mathrm{ceil}\left(x\right),x\right)$
 ${⌊{x}⌋}^{\left({1}\right)}$ (33)
 > $\mathrm{floor}\left(1,3.5\right)$
 ${0}$ (34)
 > $\mathrm{trunc}\left(1,243.422\right)$
 ${0}$ (35)

Errors are returned when the functions are not defined:

 > $\mathrm{floor}\left(1,5\right)$

References

 McDonnell, E.E. "Integer functions of complex numbers, with applications." IBM Philadelphia Scientific Center Tech. Rep. pp. 320-3015. Feb., 1973.

 See Also