Reference Guide > I–L Routines > INT32 Function
  

INT32 Function
The INT32 function has two forms that perform the following actions:
*Converts an expression to longword integer data type.
*Extracts data from an expression and places it in a longword integer scalar or array.
enabled.
Usage
This form is used to convert data.
result = INT32(expr)
This form is used to extract data.
result = INT32(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. The dimensions may be any scalar expression with up to eight dimensions specified.
Returned Value
For data conversion:
result—A copy of expr converted to longword integer data type.
For data extraction:
result—If offset is used, INT32 does not convert result, but allows fields of data extracted from expr to be treated as longword integer data. If no dimensions are specified, the result is scalar.
Keywords
None.
Discussion
Conversion usage:
If the values of expr are not within the range of a long integer, a misleading result occurs and a message may be displayed.
For example, suppose A = 2.0 ^ 31 + 2. The following commands,
B = INT32(A) 
C = INT32(–A)
produce the erroneous results of
B = 2147483647
C = –2147483648
In addition, PV-WAVE does not check for overflow during conversion to longword integer data type.
Example
In this example, INT32 is used in two ways. First, INT32 is used to convert a single-precision, floating-point array to type longword. Next, INT32 is used to extract a subarray from the longword 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.5.
a = FINDGEN(6) + 0.5
PRINT, a
; PV-WAVE prints: 
; 0.500000  1.50000  2.50000  3.50000  4.50000  5.50000
; Convert a to type longword.
b = INT32(a)
; Note that floating-point numbers in a were truncated by INT32.
INFO, b
; PV-WAVE prints: VARIABLE     INT32      = Array(6)
PRINT, b
; PV-WAVE prints: 0    1    2    3    4    5
; Extract the last four elements of b, and place them in a.
c = INT32(b, 8, 2, 2)
INFO, c
; PV-WAVE prints: 
; VARIABLE     INT32      = Array(2, 2)
; PRINT, c
;   2         3
;   4         5
See Also
BYTE, COMPLEX, DOUBLE, FIX, FLOAT, LINDGEN, LONARR, alibInt
For more information on data extraction, see the PV‑WAVE Programmer’s Guide.

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.