Main Content

roundn

(Not recommended) Round to multiple of 10n

The roundn function is not recommended. Use the round function instead. For more information, see Compatibility Considerations.

Description

example

Y = roundn(X,n) rounds each element of X to the nearest multiple of 10n.

Examples

collapse all

Round pi to the nearest hundredth.

Y = roundn(pi,-2)
Y =

    3.1400

Input Arguments

collapse all

Input array, specified as a scalar, vector, matrix, or multidimensional array. For complex values of X, the function rounds the real and imaginary parts independently.

Data Types: single | double
Complex Number Support: Yes

Exponent of 10, specified as a scalar integer.

Version History

Introduced before R2006a

collapse all

R2014b: roundn is not recommended

The roundn function is not recommended. Use the round function instead. Note that when you update your code, you must reverse the sign of n.

Not RecommendedRecommended
Y = roundn(X,n)
Y = round(X,-n)

See Also