V+ Language Reference Guide, v
FLTB real-valued function
Syntax
FLTB ($string, first_char)
Function
Return the value of four bytes of a string interpreted as an IEEE single-precision floating-point number.
Parameters
$string String expression that contains the four bytes to be converted. first_char Optional real-valued expression that specifies the position of the first of the four bytes in the string.
If first_char is omitted or has a value of 0 or 1, the first four bytes of the string are extracted. If first_char is greater than 1, it is interpreted as the character position for the first byte. For example, a value of 2 means that the second, third, fourth, and fifth bytes are extracted. An error is generated if first_char specifies four bytes that are beyond the end of the input string.
Details
Four sequential bytes of the given string are interpreted as being a single-precision (32-bit) floating-point number in the IEEE standard format. This 32-bit field is interpreted as follows:
![]()
where
s is the sign bit, s = 0 for positive, s = 1 for negative.
exp is the binary exponent, biased by -127.
fraction is a binary fraction with an implied 1 to the left of the binary point.
For 0 < exp < 255, the value of a floating-point number is:
-1s * (1.fraction) * 2exp -127For exp = 0, the value is zero; for exp = 255, an overflow error exists.
The main use of this function is to convert a binary floating-point number from an input data record to a value that can be used internally by V+.
Examples
FLTB($CHR(^H3F)+$CHR(^H80)+$CHR(0)+$CHR(0)) ;Returns 1.0 FLTB($CHR(^HC0)+$CHR(^H40)+$CHR(0)+$CHR(0)) ;Returns -3.0Related Keywords
ASC real-valued function
DBLB real-valued function
$DBLB string function
$FLTB string function
INTB real-valued function
LNGB real-valued function
$LNGB string function
TRANSB transformation function
VAL real-valued function
Submit comments to: techpubs@adept.com
Last modified on: 1/11/2012
Copyright © 1994 - 2011. Adept Technology, Inc.
