Truncation and Rounding Functions |
floor(z) Returns the greatest integer ≤
z.
Floor(z, y) Returns the greatest multiple of y ≤ z.
ceil(z) Returns the smallest integer ≥
z.
Ceil(z, y) Returns the smallest multiple of y ≥ z.
round(z, [n]) Returns z rounded to
n decimal places. If n is omitted,
returns z rounded to the nearest integer (n is assumed to be zero). If n < 0,
returns z rounded to n places to
the left of the decimal point. If the (n + 1)th decimal
place is less than 5, the number is rounded down, otherwise, it is rounded
up.
Round(z, y) Returns round(z /
y) · y, which rounds z to the closest multiple of y. Note that round(z, 1) = Round(z, 0.1).
trunc(z) Returns the integer part of z
by removing the fractional part.
Trunc(z, y) Returns trunc(z / y) · y.
z is a real or complex scalar or vector. For the lowercase functions, z must be dimensionless. For the two-argument uppercase functions, z and y must have the same dimensions.
y is a real, nonzero scalar or vector.
n is an integer.
The uppercase versions of these functions are used to correctly evaluate truncation of united values. For example, if you wish to find the ceil of x:=3.23·m in feet, use Ceil(x,ft) = 10·ft.
floor and trunc return the same results for positive values of x. For negative values of x, however, the results are different: floor(-2.6) = -3 but trunc(-2.6) = -2.
floor and ceil yield different results under symbolic evaluation for complex arguments, because Maple uses a different definition that treats the real and complex parts of the argument simultaneously.