Rounding

trunc-funktion

Removes the fractional part of the argument.

Syntax

trunc(z)

Beskrivning

The trunc function returns the heltal 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-funktion

Returns the fractional part of the argument.

Syntax

fract(z)

Beskrivning

The fract function returns the fractional part of z. The function removes the heltal 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-funktion

Rounds the argument up.

Syntax

ceil(z)

Beskrivning

The ceil function finds the smallest heltal 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-funktion

Rounds the argument down.

Syntax

floor(z)

Beskrivning

The floor function, which is also called the greatest integer function, gives the largest heltal 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-funktion

Rounds a number to the specified number of decimals.

Syntax

round(z,n)

Beskrivning

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 heltal. If n<0, z is rounded to n places to the left of the decimal point.

Exempel

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