FreeMat
|
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 = 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