ROUND Round Function
Section: Elementary Functions
Usage
Rounds an n-dimensional array to the nearest integer elementwise. The general syntax for its use isy = 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.
Example
The following demonstrates theround
function applied to various
(numerical) arguments. For integer arguments, the round function has
no effect:
--> round(3) ans = 3 --> round(-3) ans = -3
Next, we take the round
of a floating point value:
--> round(3.023f) ans = 3 --> round(-2.341f) ans = -2
Note that the return type is a float
also. Finally, for a double
type:
--> round(4.312) ans = 4 --> round(-5.32) ans = -5