round
Round to nearest integer
📝Syntax
C = round(A)
C = round(A, N)
C = round(A, N, 'decimals')
C = round(A, N, 'significant')
📥Input Arguments
Parameter Description
A a variable
N number of digits: real integer scalar.
type 'decimals' (default) or 'significant'.
📤Output Arguments
Parameter Description
C result of round.
📄Description

round rounds the elements to the nearest integers.

round(A, N) rounds to N digits to the right of the decimal point (N may be negative). This is the same as round(A, N, 'decimals').

round(A, N, 'significant') rounds to N significant digits; here N must be positive.

Sparse single and sparse single complex inputs are supported. Only stored nonzero entries are rounded and the result keeps the sparse storage and the input precision.

💡Examples
round(pi)
Round to a number of decimal or significant digits.
round(3.14159, 2)
round(12345, 2, 'significant')
Round a sparse single matrix to nearest integers.
S = sparse(single([1.2 0; -2.7 3.1]));
C = round(S)
🔗See Also
floorfixceil
🕔Version History
Version Description
1.0.0 initial version
2.0.0 sparse single and sparse single complex inputs supported.
2.0.0 round(A, N) and the 'decimals' / 'significant' options added.
Edit this page on GitHub