1.1.10 Float
A Float is an approximate numeric field that stores floating point numeric data (as opposed to fixed point like Signed and Packed). Floating point data is approximate. Not all values in the field type range can be precisely represented. Floats are classed as Numbers in LANSA.
Fields of type Float may only be used in an arithmetic expression. Floats cannot be displayed in a component or function.
A Float is defined by the number of bytes used to store the value. The higher number of bytes, the more accurate the number. A 4 byte Float is accurate while the number of digits is less than or equal to 6. An 8 byte Float is accurate while the number of digits is less than or equal to 15.
The following table provides the accurate length for each of the possible byte lengths for a Float. The accurate length may be considered equivalent to the actual length of a signed or packed field. The table also notes the possible number of decimal places at runtime.
| Accurate # digits (accurate length) | Possible decimal places |
|---|---|---|
4 | 6 | 0 - 6 |
8 | 15 | 0 - 15 |
Please review the general 1.1.1 Field Type Considerations.
Field Definition Rules
Rules for defining a Float field in the repository are:
Length | Floats may be 4 or 8 bytes in length. Decimals must always be zero. |
|---|---|
Valid Keyboard Shift | Blanks |
Allowed Attributes | AB, ASQN, CS, FE, ND, RA, RB, RL, RLTB. |
Edit Mask | Not allowed. |
Default | *NULL |
Usage Rules
Partition Type | |
|---|---|
Files | Floats may only be used in RDMLX Files. Floats may be used as real fields. Use of Floats as key fields is not recommended. |
Logical Views | Use of Floats as key fields is not recommended. |
Virtual Fields | Floats may only used with Mathematical Virtual Fields. Floats may be used as the source field(s). |
Predetermined Join Fields | Floats may be used for numeric predetermined joined fields. |
RDML Commands | Fields of type Float may only be used in an arithmetic expression. |
Built-In Functions | When used in Built-In Functions, floats are valid for arguments of type 'N'. |
Special Values | *NULL, *NAVAIL, *HIVAL, *LOVAL, *REMEMBERED_VALUE |
Conversion | It is wrong to convert Floats to/from Date and Time fields. Refer to Field Type Conversions. |
Usage Notes
- Working fields may be defined as TYPE(*FLOAT) in functions or components. If no length is specified, the default of 8 is assumed.
- Fields of type Float may only be used in an arithmetic expression. Use of a Float as a command parameter that is not an arithmetic expression will result in a FFC Error. For example, a Float cannot be used in a BEGIN_LOOP command.
- Floats are generally not considered suitable as a numeric argument to a BIF.
- Exact comparisons using Floats is not recommended due to inaccuracy of the type. For example, the value stored in the field or saved in the table may not be exactly what was assigned to the field. However, comparison to *ZERO or *SQLNULL is fine.
Platform Considerations
- Refer to Platform Considerations in 1.1.1 Field Type Considerations.
Tips & Techniques
- Floats are generally used in scientific or engineering applications and are not generally used in business applications.
- Floats are primarily supported in LANSA for use with Other Files and are not recommended for use in business applications.