ROUND Procedure

Rounds a scalar or an array of FLOAT, DOUBLE, COMPLEX, or DCOMPLEX values to the specified number of decimal points.

Usage

ROUND, x, dec_pts 

Input Parameters

x—A scalar or array of type FLOAT, DOUBLE, COMPLEX, or DCOMPLEX.

dec_pts—A scalar of type BYTE, INT, INT32, LONG, FLOAT, or DOUBLE specifying the resulting number of decimal points.

Returned Value

A scalar or array of the same data type as x containing the rounded values.

Discussion

Due to the limit of a long integer, x * 10n must be greater than or equal to the smallest long integer and less than or equal to the largest long integer. If the one or more values in x are outside of this range, a warning message is printed and the values are returned unchanged.

Example 1

x = HANNING(6)
PRINT, x, ROUND(x, 4), Format='(6F11.7)'
; PV-WAVE prints:
;  0.0000000  0.3454915  0.9045085  0.9045085  0.3454914  0.0000000
;  0.0000000  0.3455000  0.9045000  0.9045000  0.3455000  0.0000000

Example 2

x = 0.6D - HANNING(8)
y = DCOMPLEX(x(0:3), x(4:7))
PM, y
; PV-WAVE prints:
; (      0.60000000,     -0.35048440)
; (      0.41174490,    -0.011260533)
; (    -0.011260474,      0.41174502)
; (     -0.35048445,      0.60000000)
PM, ROUND(y, 2)
; PV-WAVE prints:
; (      0.60000000,     -0.35000000)
; (      0.41000000,    -0.010000000)
; (    -0.010000000,      0.41000000)
; (     -0.35000000,      0.60000000)