The ROUND function rounds the argument to its closest integer.

Examples


Print the rounded values of a 2-element vector:

PRINT, ROUND([5.1, 5.9])

IDL prints:

     5      6

Print the result of rounding 3000000000.1, a value that is too large to represent in a 32-bit integer:

PRINT, ROUND(3000000000.1D, /L64)

IDL prints:

3000000000

Syntax


Result = ROUND(X [, /L64 ] )

Return Value


Returns the integer closest to its argument. If the input value X is integer type, Result has the same value and type as X. Otherwise, Result is returned as a 32-bit longword integer with the same structure as X.

Arguments


X

The value for which the ROUND function is to be evaluated. This value can be any numeric type (integer, floating, or complex). Note that only the real part of a complex argument is rounded and returned.

Keywords


L64

If set, the result type is 64-bit integer no matter what type the input has. This is useful for situations in which a floating point number contains a value too large to be represented in a 32-bit integer.

Thread Pool Keywords

This routine is written to make use of IDL’s thread pool, which can increase execution speed on systems with multiple CPUs. The values stored in the !CPU system variable control whether IDL uses the thread pool for a given computation. In addition, you can use the thread pool keywords TPOOL_MAX_ELTS, TPOOL_MIN_ELTS, and TPOOL_NOTHREAD to override the defaults established by !CPU for a single invocation of this routine. See Thread Pool Keywords for details.

Version History


Pre-4.0

Introduced

See Also


CEILCOMPLEXROUNDFLOOR