Fast/Reload Float handling: Difference between revisions
m (add category) |
m (1 revision: from Stage) |
(No difference)
|
Latest revision as of 01:41, 19 February 2016
The two contexts in which floating point values are processed by Fast/Reload are:
- When the field being loaded into is defined as a FLOAT field.
- When the input value is a floating point value and the field being loaded into is defined as any type other than FLOAT.
These two contexts are discussed in the following sections.
As a brief background, note the following:
- Floating point values use the IBM hexadecimal floating point representation, which is a one-bit
sign, a 7-bit base 16 exponent, and a binary fraction whose
length is either 3 bytes (
FLOAT LEN 4
), 7 bytes (FLOAT LEN 8
), or 14 bytes (FLOAT LEN 16
). - In a normalized floating point number, the high-order nibble (the first four bits) of the fraction has a non-zero value.
Loading into FLOAT fields
An input value to be loaded into a field defined as FLOAT is processed in three different ways, depending on whether the input is provided with the X'0080' mode bit, or, if not, whether the input is a non-floating point source or is a floating point source:
X'0080' mode | In a non-LAI load, if the value being loaded is due to one of the file load statements with the X'0080' bit set (indicating float input), the floating point value is used as it is.
If the input value is shorter than the field being loaded into, the fraction part of the field is padded on the right with binary zeros. If the input value is longer than the field being loaded into, the fraction part of the field is truncated to the length of the field. Otherwise (lengths the same) it is copied unchanged to the field occurrence. | ||||||||
---|---|---|---|---|---|---|---|---|---|
Non-float | Input that is a non-float value (in either an LAI or non-LAI load) is first converted to the 8-byte floating point value that is closest to the 15-digit decimal representation of the input. Then it is treated as an 8-byte float input value, as described next. | ||||||||
Float | If the input is a float value not due to the X'0080' mode bit (such an input can only occur in a LAI load), if the length of the input is the same as the length of the field, it is copied unchanged to the field occurrence. Otherwise, it is processed according to the length of the input value and the length of the field:
|
Loading float values into non-FLOAT fields
Loading a floating point input value into a non-FLOAT field depends on whether the input value is 4 bytes long or not:
4-byte float input | A 4-byte floating point input value being loaded into a non-FLOAT field is first converted to a 6-digit decimal number closest to the value of the floating point input. |
8-byte or 16-byte float input | An 8-byte or 16-byte floating point input value being loaded into a non-FLOAT field is first converted to a 15-digit decimal number closest to the value of the floating point input. |
The resulting decimal number is then stored into the field being loaded, according to the rules for the defined field type.