FLOAT Function
The FLOAT function does the following:
Converts an expression to single-precision floating-point data type.
Extracts data from an expression and places it in a single-precision floating-point scalar or array.
enabled.
Usage
This form is used to convert data:
result = FLOAT(expr)
This form is used to extract data:
result = FLOAT(expr, offset, [dim1, ..., dimn ])
Input Parameters
To convert data:
expr—The expression to be converted, or from which to extract data.
To extract data:
expr—The expression to be converted, or 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 single-precision floating-point data type.
For data extraction:
result—If offset is used, FLOAT does not convert result, but allows fields of data extracted from expr to be treated as single-precision floating-point data. If no dimensions are specified, the result is scalar.
Keywords
None.
Example
In this example, FLOAT is used in two ways. First, FLOAT is used to convert an integer array to single precision, floating point. Next, FLOAT is used to extract a subarray from the single-precision array created in the first step.
; Create an integer vector of length 6. Each element has
; a value equal to its one-dimensional subscript.
a = INDGEN(6)
PRINT, a
; PV-WAVE prints: 0 1 2 3 4 5
; Convert a to single precision, floating point.
b = FLOAT(a)
INFO, b
; PV-WAVE prints: B FLOAT = Array(6)
PRINT, b
; PV-WAVE prints:
; 0.00000 1.00000 2.00000 3.00000 4.00000
; 5.00000
; Extract the last four elements of b, and place them in
; a 2-by-2 single-precision, floating-point array.
c = FLOAT(b, 8, 2, 2)
INFO, c
; PV-WAVE prints: C FLOAT = Array(2, 2)
PRINT, c
; PV-WAVE prints:
; 2.00000 3.00000
; 4.00000 5.00000
See Also
For more information on using this function to extract data, see the PV‑WAVE Programmer’s Guide.
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.