ROUND Round Function

Section: Elementary Functions


Rounds an n-dimensional array to the nearest integer elementwise. The general syntax for its use is
   y = round(x)

where x is a multidimensional array of numerical type. The round function preserves the type of the argument. So integer arguments are not modified, and float arrays return float arrays as outputs, and similarly for double arrays. The round function is not defined for complex or dcomplex types.


The following demonstrates the round function applied to various (numerical) arguments. For integer arguments, the round function has no effect:
--> round(3)

ans = 

--> round(-3)

ans = 

Next, we take the round of a floating point value:

--> round(3.023f)

ans = 

--> round(-2.341f)

ans = 

Note that the return type is a float also. Finally, for a double type:

--> round(4.312)

ans = 

--> round(-5.32)

ans =