Ada Resource Association
News and resources for the Ada programming language
Annotated Ada Reference ManualLegal Information
Contents   Index   References   Search   Previous   Next 

J.3 Reduced Accuracy Subtypes

1
A digits_constraint may be used to define a floating point subtype with a new value for its requested decimal precision, as reflected by its Digits attribute. Similarly, a delta_constraint may be used to define an ordinary fixed point subtype with a new value for its delta, as reflected by its Delta attribute. 
1.a
Discussion: It might be more direct to make these attributes specifiable via an attribute_definition_clause, and eliminate the syntax for these _constraints.

Syntax

2
delta_constraint ::= delta static_expression [range_constraint]

Name Resolution Rules

3
{expected type (delta_constraint expression) [partial]} The expression of a delta_constraint is expected to be of any real type. 

Legality Rules

4
The expression of a delta_constraint shall be static.
5
For a subtype_indication with a delta_constraint, the subtype_mark shall denote an ordinary fixed point subtype.
6
{notwithstanding} For a subtype_indication with a digits_constraint, the subtype_mark shall denote either a decimal fixed point subtype or a floating point subtype (notwithstanding the rule given in 3.5.9 that only allows a decimal fixed point subtype). 
6.a/2
This paragraph was deleted.Discussion: {AI95-00114-01} We may need a better way to deal with obsolescent features with rules that contradict those of the non-obsolescent parts of the standard. 

Static Semantics

7
A subtype_indication with a subtype_mark that denotes an ordinary fixed point subtype and a delta_constraint defines an ordinary fixed point subtype with a delta given by the value of the expression of the delta_constraint. If the delta_constraint includes a range_constraint, then the ordinary fixed point subtype is constrained by the range_constraint.
8
A subtype_indication with a subtype_mark that denotes a floating point subtype and a digits_constraint defines a floating point subtype with a requested decimal precision (as reflected by its Digits attribute) given by the value of the expression of the digits_constraint. If the digits_constraint includes a range_constraint, then the floating point subtype is constrained by the range_constraint.

Dynamic Semantics

9
{compatibility (delta_constraint with an ordinary fixed point subtype) [partial]} A delta_constraint is compatible with an ordinary fixed point subtype if the value of the expression is no less than the delta of the subtype, and the range_constraint, if any, is compatible with the subtype.
10
{compatibility (digits_constraint with a floating point subtype) [partial]} A digits_constraint is compatible with a floating point subtype if the value of the expression is no greater than the requested decimal precision of the subtype, and the range_constraint, if any, is compatible with the subtype.
11
{elaboration (delta_constraint) [partial]} The elaboration of a delta_constraint consists of the elaboration of the range_constraint, if any. 
11.a
Reason: A numeric subtype is considered “constrained” only if a range constraint applies to it. The only effect of a digits_constraint or a delta_constraint without a range_constraint is to specify the value of the corresponding Digits or Delta attribute in the new subtype. The set of values of the subtype is not “constrained” in any way by such _constraints. 

Wording Changes from Ada 83

11.b
In Ada 83, a delta_constraint is called a fixed_point_constraint, and a digits_constraint is called a floating_point_constraint. We have adopted other terms because digits_constraints apply primarily to decimal fixed point types now (they apply to floating point types only as an obsolescent feature). 

Contents   Index   References   Search   Previous   Next 
Ada-Europe Sponsored by Ada-Europe