The FIX function converts a given expression to an integer type. Optionally, the conversion type can be specified at runtime, allowing flexible runtime type-conversion to arbitrary types.

Note: The default behavior is to truncate to an integer type.


Convert the floating-point array [2.2, 3.0, 4.5, 5.7] to integer type and store the new array in the variable I by entering:

I = FIX([2.2, 3.0, 4.5, 5.7])

IDL returns:

2        3        4        5


Result = FIX( Expression [Offset [D1[, ..., D8]]] [, /PRINT]
   [, TYPE=typecode{1 to 15}] )

Return Value

Returns an integer value or array of the same dimensions as the Expression. If Expression is a complex number, FIX returns the real part.



The expression to be converted.


Offset from beginning of the Expression data area. Specifying this argument allows fields of data extracted from Expression to be treated as integer data.

The Offset and Dimi arguments are not allowed when converting to or from the string type.


When extracting fields of data, the Di arguments specify the dimensions of the result. If no dimension arguments are given, the result is taken to be scalar.

The Di arguments can be either an array or a series of scalar expressions specifying the dimensions of the result. If a single argument is specified, it can be either a scalar expression or an array of up to eight elements. If multiple arguments are specified, they must all be scalar expressions. Up to eight dimensions can be specified.

The Offset and Di arguments are not allowed when converting to or from the string type.



Set this keyword to format the result using the same formatting rules as Implied Print. This keyword is ignored unless the TYPE keyword is set to 7 (STRING).


Set this keyword to specify that any special-case processing when converting between string and byte data, or the reverse, should be suppressed. The PRINT keyword is ignored unless the TYPE keyword is set to either 1 (BYTE) or 7 (STRING).


FIX normally converts Expression to the integer type. If TYPE is specified, Expression is converted to the specified type. (See IDL Type Codes and Names for a list of type codes.) When TYPE is specified, FIX behaves as if the appropriate type conversion routine for the desired type had been called. See the See Also list below for the complete list of such routines.

When using the TYPE keyword to convert BYTE data to STRING or the reverse, you should be aware of the special-case processing that the BYTE and STRING functions do in this case. To prevent this, and get a simple type conversion in these cases, you must specify the PRINT keyword.

Attempts to convert to TYPE=0 (Undefined) are quietly ignored.

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



See Also