Rounding

trunc function

Removes the fractional part of the argument.

Syntax

trunc(z)

Description

The trunc function returns the integer part of z. The function removes the decimal part of z, i.e. rounds against zero. z may be any numeric expression that evaluates to a real number or a complex number. If z is a complex number, the function returns trunc(re(z))+trunc(im(z))i.

fract function

Returns the fractional part of the argument.

Syntax

fract(z)

Description

The fract function returns the fractional part of z. The function removes the integer part of z, i.e. fract(z) = z - trunc(z). z may be any numeric expression that evaluates to a real number or a complex number. If z is a complex number, the function returns fract(re(z))+fract(im(z))i.

ceil function

Rounds the argument up.

Syntax

ceil(z)

Description

The ceil function finds the smallest integer not less than z. z may be any numeric expression that evaluates to a real number or a complex number. If z is a complex number, the function returns ceil(re(z))+ceil(im(z))i.

floor function

Rounds the argument down.

Syntax

floor(z)

Description

The floor function, which is also called the greatest integer function, gives the largest integer not greater than z. z may be any numeric expression that evaluates to a real number or a complex number. If z is a complex number, the function returns floor(re(z))+floor(im(z))i.

round function

Rounds a number to the specified number of decimals.

Syntax

round(z,n)

Description

The round function rounds z to the number of decimals given by n. z may be any numeric expression that evaluates to a real number or a complex number. If z is a complex number, the function returns round(re(z),n)+round(im(z),n)i. n may be any numeric expression that evaluates to an integer. If n<0, z is rounded to n places to the left of the decimal point.

Examples

round(412.4572,3) = 412.457
round(412.4572,2) = 412.46
round(412.4572,1) = 412.5
round(412.4572,0) = 412
round(412.4572,-2) = 400