FIX Function
The FIX function does the following:
*Converts an expression to integer data type.
*Extracts data from an expression and places it in a integer scalar or array.
enabled.
Usage
This form is used to convert data:
result = FIX(expr)
This form is used to extract data:
result = FIX(expr, offset, [dim1, ..., dimn ])
Input Parameters
To convert data:
expr—The expression to be converted.
To extract data:
expr—The expression from which to extract data.
offset—The offset, in bytes, from the beginning of expr to where the extraction is to begin.
dimi—(optional) The dimensions of the result. May be any scalar expression. Up to eight dimensions may be specified.
Returned Value
For data conversion:
result—A copy of expr converted to integer data type.
For data extraction:
result—If offset is used, FIX does not convert result, but allows fields of data extracted from expr to be treated as integer data. If no dimensions are specified, the result is scalar.
Keywords
None.
Discussion
If the values of expr are within the range of a long integer, but outside the range of the integer data type, a misleading result occurs, without an accompanying message. For example, FIX(66000) erroneously results in 464.
In addition, PV-WAVE does not check for overflow during conversion to integer data type. The values in expr are simply converted to long integers and the low 16 bits are extracted.
Examples
FIX is used in two ways here. First, FIX is used to convert a single-precision, floating- point array to integer. Next, FIX is used to extract a subarray from the integer array created in the first step.
; Create single precision, floating point vector of length 6.
; Each element has a value equal to its one-dimensional
; subscript plus 0.6.
a = FINDGEN(6) + 0.6 
 
PRINT, a
; PV-WAVE prints:
;  0.600000      1.60000      2.60000      3.60000
;  4.60000      5.60000
 
; Convert a to type integer.
b = FIX(a)
 
INFO, b
; PV-WAVE prints: B         INT       = Array(6)
 
PRINT, b
; PV-WAVE prints: 0    1    2    3    4    5
; Notice that the floating-point numbers in a
; were truncated by FIX.
 
; Extract the last four elements of b, and place them
; in a 2-by-2 integer array.
c = FIX(b, 4, 2, 2)	
INFO, c
; PV-WAVE prints: C         INT        = Array(2, 2)
PRINT, c
; PV-WAVE prints:
;  2       3
;  4       5
See Also
For more information on using this function to extract data, see the PV‑WAVE Programmer’s Guide.