Fast/Reload Float handling

From m204wiki
Revision as of 01:41, 19 February 2016 by Admin (talk | contribs) (1 revision: from Stage)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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:
4-byte input To store a 4-byte input float value (in an LAI load) into a length 8 or 16 FLOAT field, the 4-byte value is converted to an 8-byte value which is closest to the 6-digit decimal value closest to the 4-byte float input. This 8-byte value is stored unchanged in a FLOAT LEN 8 field, or the fraction is padded on the right with binary zeroes to store into a FLOAT LEN 16 field.
8-byte or 16-byte input
to FLOAT LEN 4
To store FLOAT LEN 4 from an 8 or 16-byte input, the first 8 bytes of the input are used; this float value is then "hex rounded" to a FLOAT LEN 4, without normalization. That is, the first 24 bits of the fraction are used, incremented by 1 if the 25th fraction bit is 1; if this overflows the 24 bit fraction, the exponent is adjusted, otherwise it is copied.
8-byte input
to FLOAT LEN 16
To store an 8-byte input float value into a FLOAT LEN 16 field, eight bytes of binary zero are padded on the right.
16-byte input
to FLOAT LEN 8
To store a 16-byte input float value into a FLOAT LEN 8 field, the first 8 bytes of the input are used.

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.

See also