vec_round

Purpose

Returns a vector containing the rounded values of the corresponding elements of the given vector.

Syntax

d=vec_round(a)

Result and argument types

The following table describes the types of the returned value and the function arguments.

d a
vector4double vector4double

Result value

Each element of the result contains the value of the corresponding element of a, rounded to the nearest representable floating-point integer.

Formula

For each element of a:

If a[n] <0, d[n] = (a[n] – 0.5), truncated to the nearest integral value.
If a[n] >0, d[n] = (a[n] + 0.5), truncated to the nearest integral value.
If a[n] EQ 0, d[n] = 0.
Note: EQ is the equal operator.

Example

ARG1  = (-5.8, -2.3, 2.3, 5.8)
Result: (-6.0, -2.0, 2.0, 6.0)