Function: math[roundf] - rounds real values to the n-th digit

Calling Sequence:

roundf(expr);

roundf(expr, n);
roundf(expr, n, 'adjust');

Parameters:

expr - any algebraic expression
n - an integer
'adjust' - (optional) the name (accuracy option)

Description:

If n > 0, then math/roundf rounds all floats in an expression to the n-th fractional digit. Numeric values that are not of type float are not rounded in this case.

If n = 0 (in this case the second argument may be omitted), then math/roundf rounds all floats in an expression to the nearest integer. This is equivalent to the round function. Here, integers and fractions are ignored, as well.

If n < 0, math/roundf rounds any value v in expr that is of type integer, fraction, or float, to the first n digits from the right of trunc(v).

Note that with negative values v in expr, roundf returns -roundf(-v, n).

In the third form, if the option 'adjust' is passed as the third argument to roundf and if x is of type float, the value of Digits is set to length(op(1, x)). If x is not of type float, in some cases you have to reset Digits in order to acquire maximum accuracy. Here the adjust option is unnecessary. See example below.

This function is part of the math package, and so can be used only after performing the command with(math) or with(math, roundf).

Examples:

> with(math, roundf):

> roundf(3.141592654, 4);

[Maple Math]

> roundf(31415.264, 5);

[Maple Math]

> roundf(3);

[Maple Math]

> roundf(-1779.192*x^2+x, 1);

[Maple Math]

Note ! roundf(x^n, -1) -> x^0 = 1

> roundf(-1779.192*x^2+x, -1);

[Maple Math]

> roundf(-0.009, 1);

[Maple Math]

> fl := evalf(1/7, 30);

[Maple Math]

> roundf(fl, 23);

[Maple Math]

> roundf(fl, 23, adjust);

[Maple Math]

> roundf(10000/1367, 1);

[Maple Math]

See Also:

round , math/slice .

Version History:

Version 1.0 - April 18, 1998

Version 2.0 - June 02, 1998