5. Embedded QUEL for Ada : Ada Variables and Data Types : Variable and Type Declarations : Floating-point Type Definitions
 
Share this page                  
Floating-point Type Definitions
The syntax of an EQUEL/Ada floating-point type definition is:
digits digit_specification [range_constraint]
In the context of a type declaration the syntax is:
type identifier is digits digit_specification [range_constraint];
The syntax of a floating-point subtype declaration is:
subtype identifier is floating_type_name
              [digits digit_specification]
              [range_constraint];
Syntax Notes:
1. The value of digit_specification must be an integer literal. Based on
the value of the specification, EQUEL will determine whether to treat a variable of that type as a 4-byte float or an 8-byte float. The rules in the following table are applicable.
Digit Range
Type
1 < = d < = 6
4-byte floating-point type
7 < = d < = 16
8-byte floating-point type
Note that if the digits specified are out of range, the type is unusable. Recall that EQUEL does not accept either the long_long_float or the h_float type. For detailed information on the internal storage format for 8-byte floating-point variables, see The Long Float Storage Format.
2. The range_constraint for floating-point types and subtypes is treated
as a variable range constraint and is not processed. Although EQUEL will allow any range constraint, you should not specify a range constraint that will alter the size needed to store the declared type. EQUEL obtains its type information from the digits clause, and altering this type information by a range clause, which may require more precision, will result in runtime errors.
3. The digits clause in a subtype declaration does not have any effect
on the EQUEL type information. This information is obtained from floating_type_name. For example:
## type Emp_Salary   is digits 8 range
                    0.00..500000.00;

## subtype Directors_Sal is Emp_Salary
                    100500.00..500000.00;
## subtype Raise_Percent is Float range 1.05..1.20;