# 3.5.10 Operations of Fixed Point Types

#### Static Semantics

1
The following attributes are defined for every fixed point subtype S:
2/1
S'Small
{8652/0005} {AI-00054-01} S'Small denotes the small of the type of S. The value of this attribute is of the type universal_real. {specifiable (of Small for fixed point types) [partial]} {Small clause} Small may be specified for nonderived ordinary fixed point types via an attribute_definition_clause (see 13.3); the expression of such a clause shall be static.
3
S'Delta
S'Delta denotes the delta of the fixed point subtype S. The value of this attribute is of the type universal_real
3.a
Reason: The delta is associated with the subtype as opposed to the type, because of the possibility of an (obsolescent) delta_constraint.
4
S'Fore
S'Fore yields the minimum number of characters needed before the decimal point for the decimal representation of any value of the subtype S, assuming that the representation does not include an exponent, but includes a one-character prefix that is either a minus sign or a space. (This minimum number does not include superfluous zeros or underlines, and is at least 2.) The value of this attribute is of the type universal_integer.
5
S'Aft
S'Aft yields the number of decimal digits needed after the decimal point to accommodate the delta of the subtype S, unless the delta of the subtype S is greater than 0.1, in which case the attribute yields the value one. [(S'Aft is the smallest positive integer N for which (10**N)*S'Delta is greater than or equal to one.)] The value of this attribute is of the type universal_integer.
6
The following additional attributes are defined for every decimal fixed point subtype S:
7
S'Digits
S'Digits denotes the digits of the decimal fixed point subtype S, which corresponds to the number of decimal digits that are representable in objects of the subtype. The value of this attribute is of the type universal_integer. Its value is determined as follows: {digits (of a decimal fixed point subtype)}
8
• For a first subtype or a subtype defined by a subtype_indication with a digits_constraint, the digits is the value of the expression given after the reserved word digits;
9
• For a subtype defined by a subtype_indication without a digits_constraint, the digits of the subtype is the same as that of the subtype denoted by the subtype_mark in the subtype_indication.
9.a
Implementation Note: Although a decimal subtype can be both range-constrained and digits-constrained, the digits constraint is intended to control the Size attribute of the subtype. For decimal types, Size can be important because input/output of decimal types is so common.
10
• The digits of a base subtype is the largest integer D such that the range –(10**D–1)*delta .. +(10**D–1)*delta is included in the base range of the type.
11
S'Scale
S'Scale denotes the scale of the subtype S, defined as the value N such that S'Delta = 10.0**(–N). {scale (of a decimal fixed point subtype)} [The scale indicates the position of the point relative to the rightmost significant digits of values of subtype S.] The value of this attribute is of the type universal_integer
11.a
Ramification: S'Scale is negative if S'Delta is greater than one. By contrast, S'Aft is always positive.
12
S'Round
S'Round denotes a function with the following specification:
13
function S'Round(X : universal_real)
return S'Base
14
The function returns the value obtained by rounding X (away from 0, if X is midway between two values of the type of S).
NOTES
15
39  All subtypes of a fixed point type will have the same value for the Delta attribute, in the absence of delta_constraints (see J.3).
16
40  S'Scale is not always the same as S'Aft for a decimal subtype; for example, if S'Delta = 1.0 then S'Aft is 1 while S'Scale is 0.
17
41  {predefined operations (of a fixed point type) [partial]} The predefined operations of a fixed point type include the assignment operation, qualification, the membership tests, and explicit conversion to and from other numeric types. They also include the relational operators and the following predefined arithmetic operators: the binary and unary adding operators – and +, multiplying operators, and the unary operator abs.
18
42  As for all types, objects of a fixed point type have Size and Address attributes (see 13.3). Other attributes of fixed point types are defined in A.5.4.

#### Wording Changes from Ada 95

18.a/2
{8652/0005} {AI95-00054-01} Corrigendum: Clarified that small may be specified only for ordinary fixed point types.