ROUND [numberOfPlaces] inputVector resultVariable

Replaces the contents of the result variable with the rounded value of each of the elements of the input vector. If numberOfPlaces is absent or zero, then each element is rounded to the nearest integer. If numberOfPlaces is positive, then each element is rounded to that number of places after the decimal point. If numberOfPlaces is negative, then each element is rounded to that number of places before the decimal point. If the number is exactly halfway between two nearest numbers, it is rounded up, i.e., toward positive infinity.

If an element is NaN ("missing", or "Not a Number"), it will round to NaN. If you want to remove NaNs from your vectors, use the CLEAN command.

See also the INTEGER and FRACTION commands.

COPY (1.5 -1.5 1.499999999 -1.499999999 2.3 2.05) A
ROUND A B
PRINT A B

The above program produced the following result:

A: (1.5 -1.5 1.499999999 -1.499999999 2.3 2.05)
B: (2.0 -1.0 1.0 -1.0 2.0 2.0)

If you want to round to a given number of decimal places instead of just to integers, you can use the numberOfPlaces argument. Here is a simple example program that demonstrates rounding to two decimal places:

NORMAL 5 0 1 vec          'Create some random data
ROUND 2 vec vecRounded    'Round to two digits
PRINT vec vecRounded      'Print the results

Which produced the following on one run:

vec: (-0.1788212265770708 -0.18404241450986658 -0.5091394051656403 0.7518794477726501 -0.2779965807870344)
vecRounded: (-0.18 -0.18 -0.51 0.75 -0.28)

Here's a program demonstrating rounding to thousand's place:

NORMAL 5 100000 1000 vec  'Create some random data
ROUND -3 vec vecRounded   'Round to thousand's place
PRINT vec vecRounded      'Print the results

Here is the output from one run:

vec: (99808.38130810017 100752.10468310244 99310.80466882866 98027.29904808488 99919.00130251558)
vecRounded: (100000.0 101000.0 99000.0 98000.0 100000.0)