[Home] [Prev] [Next] [Index]

Operations of Floating Point Types

3.5.8 Operations of Floating Point Types

1
The basic operations of a floating point type include the operations involved in assignment, membership tests, qualification, the explicit conversion of values of other numeric types to the floating point type, and the implicit conversion of values of the type universal_real to the type.

2
In addition, for every floating point type or subtype T, the basic operations include the attributes listed below. In this presentation, T is referred to as being a subtype (the subtype T) for any property that depends on constraints imposed by T; other properties are stated in terms of the base type of T.

3
The first group of attributes yield characteristics of the subtype T. The attributes of this group are the attribute BASE (see 3.3.2), the attributes FIRST and LAST (see 3.5), the representation attribute SIZE (see 13.7.2), and the following attributes:

4 T'DIGITSYields the number of decimal digits in the decimal mantissa of model numbers of the subtype T. (This attribute yields the number D of section 3.5.7.) The value of this attribute is of the type universal_integer.
5 T'MANTISSA   Yields the number of binary digits in the binary mantissa of model numbers of the subtype T. (This attribute yields the number B of section 3.5.7.) The value of this attribute is of the type universal_integer.
6 T'EPSILONYields the absolute value of the difference between the model number 1.0 and the next model number above, for the subtype T. The value of this attribute is of the type universal_real.
7 T'EMAXYields the largest exponent value in the binary canonical form of model numbers of the subtype T. (This attribute yields the product 4*B of section 3.5.7.) The value of this attribute is of the type universal_integer.
8 T'SMALLYields the smallest positive (nonzero) model number of the subtype T. The value of this attribute is of the type universal_real.
9 T'LARGEYields the largest positive model number of the subtype T. The value of this attribute is of the type universal_real.
10
The attributes of the second group include the following attributes which yield characteristics of the safe numbers:

11 T'SAFE_EMAXYields the largest exponent value in the binary canonical form of safe numbers of the base type of T. (This attribute yields the number E of section 3.5.7.) The value of this attribute is of the type universal_integer.
12 T'SAFE_SMALLYields the smallest positive (nonzero) safe number of the base type of T. The value of this attribute is of the type universal_real.
13 T'SAFE_LARGE   Yields the largest positive safe number of the base type of T. The value of this attribute is of the type universal_real.
14
In addition, the attributes A'SIZE and A'ADDRESS are defined for an object A of a floating point type (see 13.7.2). Finally, for each floating point type there are machine-dependent attributes that are not related to model numbers and safe numbers. They correspond to the attribute designators MACHINE_RADIX, MACHINE_MANTISSA, MACHINE_EMAX, MACHINE_EMIN, MACHINE_ROUNDS, and MACHINE_OVERFLOWS (see 13.7.3).

15
Besides the basic operations, the operations of a floating point type include the relational operators, and the following predefined arithmetic operators: the binary and unary adding operators - and +, the multiplying operators * and /, the unary operator abs, and the exponentiating operator.

16
The operations of a subtype are the corresponding operations of the type except for the following: assignment, membership tests, qualification, explicit conversion, and the attributes of the first group; the effects of these operations are redefined in terms of the subtype.

Notes:

17
The attributes EMAX, SMALL, LARGE, and EPSILON are provided for convenience. They are all related to MANTISSA by the following formulas:

T'EMAX = 4*T'MANTISSA
T'EPSILON = 2.0**(1 - T'MANTISSA)
T'SMALL = 2.0**(-T'EMAX - 1)
T'LARGE = 2.0**T'EMAX * (1.0 - 2.0**(-T'MANTISSA))

18
The attribute MANTISSA, giving the number of binary digits in the mantissa, is itself related to DIGITS. The following relations hold between the characteristics of the model numbers and those of the safe numbers:

T'BASE'EMAX <= T'SAFE_EMAX
T'BASE'SMALL >= T'SAFE_SMALL
T'BASE'LARGE <= T'SAFE_LARGE

19
The attributes T'FIRST and T'LAST need not yield model or safe numbers. If a certain number of digits is specified in the declaration of a type or subtype T, the attribute T'DIGITS yields this number.

20
References:

*
abs operator 4.5

*
abs operator 4.5.6

*
arithmetic operator 3.5.5

*
arithmetic operator 4.5

*
assignment 5.2

*
attribute 4.1.4

*
base type 3.3

*
basic operation 3.3.3

*
binary adding operator 4.5

*
binary adding operator 4.5.3

*
bound of a range 3.5

*
constraint 3.3

*
conversion 4.6

*
digit 2.1

*
exponentiating operator 4.5

*
exponentiating operator 4.5.6

*
floating point type 3.5.7

*
membership test 4.5

*
membership test 4.5.2

*
model number 3.5.6

*
multiplying operator 4.5

*
multiplying operator 4.5.5

*
numeric type 3.5

*
object 3.2

*
operation 3.3

*
predefined operator 4.5

*
qualified expression 4.7

*
relational operator 4.5

*
relational operator 4.5.2

*
safe number 3.5.6

*
subtype 3.3

*
type 3.3

*
unary adding operator 4.5

*
unary adding operator 4.5.4

*
universal type 4.10

*
universal_integer type 3.5.4

*
universal_real type 3.5.6

3.5.9 Fixed Point Types

1
For fixed point types, the error bound is specified as an absolute value, called the delta of the fixed point type.

2
fixed_point_constraint ::=
     fixed_accuracy_definition [range_constraint]

fixed_accuracy_definition ::=
     delta static_simple_expression

3
The delta is specified by the value of the static simple expression of the fixed accuracy definition. This value must belong to some real type and must be positive (nonzero). If the fixed point constraint is used as a real type definition, then it must include a range constraint; each bound of the specified range must be defined by a static expression of some real type but the two bounds need not have the same real type. If the fixed point constraint is used in a subtype indication, the range constraint is optional.

4
A canonical form is defined for any fixed point model number other than zero. In this form: sign is either +1 or -1; mantissa is a positive (nonzero) integer; and any model number is a multiple of a certain positive real number called small, as follows:

sign * mantissa * small

5
For the model numbers defined by a fixed point constraint, the number small is chosen as the largest power of two that is not greater than the delta of the fixed accuracy definition. Alternatively, it is possible to specify the value of small by a length clause (see 13.2), in which case model numbers are multiples of the specified value. The guaranteed minimum accuracy of operations of a fixed point type is defined in terms of the model numbers of the fixed point constraint that forms the corresponding real type definition (see 4.5.7).

6
For a fixed point constraint that includes a range constraint, the model numbers comprise zero and all multiples of small whose mantissa can be expressed using exactly B binary digits, where the value of B is chosen as the smallest integer number for which each bound of the specified range is either a model number or lies at most small distant from a model number. For a fixed point constraint that does not include a range constraint (this is only allowed after a type mark, in a subtype indication), the model numbers are defined by the delta of the fixed accuracy definition and by the range of the subtype denoted by the type mark.

7
An implementation must have at least one anonymous predefined fixed point type. The base type of each such fixed point type is the type itself. The model numbers of each predefined fixed point type comprise zero and all numbers for which mantissa (in the canonical form) has the number of binary digits returned by the attribute MANTISSA, and for which the number small has the value returned by the attribute SMALL.

8
A fixed point type declaration of the form:

type T is delta D range L .. R;

9
is, by definition, equivalent to the following declarations:

type fixed_point_type is new predefined_fixed_point_type;
subtype T is fixed_point_type
range fixed_point_type(L) .. fixed_point_type(R);

10
In these declarations, fixed_point_type is an anonymous type, and the predefined fixed point type is implicitly selected by the implementation so that its model numbers include the model numbers defined by the fixed point constraint (that is, by D, L, and R, and possibly by a length clause specifying small).

11
The fixed point declaration is illegal if no predefined type satisfies these requirements. The safe numbers of a fixed point type are the model numbers of its base type.

12
The elaboration of a fixed point type declaration consists of the elaboration of the equivalent type and subtype declarations.

13
If the fixed point constraint follows a type mark in a subtype indication, the type mark must denote a fixed point type or subtype. The fixed point constraint is compatible with the type mark only if the delta specified by the fixed accuracy definition is not smaller than the delta for the type or subtype denoted by the type mark. Furthermore, if the fixed point constraint includes a range constraint, the fixed point constraint is compatible with the type mark only if the range constraint is, itself, compatible with the type mark.

14
The elaboration of such a subtype indication includes the elaboration of the range constraint, if there is one; it creates a fixed point subtype whose model numbers are defined by the corresponding fixed point constraint and also by the length clause specifying small, if there is one. A value of a fixed point type belongs to a fixed point subtype if and only if it belongs to the range defined by the subtype.

15
The same arithmetic operators are predefined for all fixed point types (see 4.5). Multiplication and division of fixed point values deliver results of an anonymous predefined fixed point type that is called universal_fixed in this reference manual; the accuracy of this type is arbitrarily fine. The values of this type must be converted explicitly to some numeric type.

Notes:

16
If S is a subtype of a fixed point type or subtype T, then the set of model numbers of S is a subset of those of T. If a length clause has been given for T, then both S and T have the same value for small. Otherwise, since small is a power of two, the small of S is equal to the small of T multiplied by a nonnegative power of two.

17
A range constraint is allowed in a fixed point subtype indication, either directly after the type mark, or as part of a fixed point constraint. In either case the bounds of the range must belong to the base type of the type mark (see 3.5).

18
Examples:

type VOLT is delta 0.125 range 0.0 .. 255.0;
subtype ROUGH_VOLTAGE is VOLT delta 1.0; -- same range
-- as VOLT

-- A pure fraction which requires all the available
-- space in a word on a two's complement machine can be
-- declared as the type FRACTION:

DEL : constant := 1.0/2**(WORD_LENGTH - 1);
type FRACTION is delta DEL range -1.0 .. 1.0 - DEL;

19
References:

*
anonymous type 3.3.1

*
arithmetic operator 3.5.5

*
arithmetic operator 4.5

*
base type 3.3

*
belong to a subtype 3.3

*
bound of a range 3.5

*
compatible 3.3.2

*
conversion 4.6

*
elaboration 3.9

*
error bound 3.5.6

*
length clause 13.2

*
model number 3.5.6

*
numeric type 3.5

*
operation 3.3

*
predefined operator 4.5

*
range constraint 3.5

*
real type 3.5.6

*
real type definition 3.5.6

*
safe number 3.5.6

*
simple expression 4.4

*
static expression 4.9

*
subtype 3.3

*
subtype declaration 3.3.2

*
subtype indication 3.3.2

*
type 3.3

*
type declaration 3.3.1

*
type mark 3.3.2

3.5.10 Operations of Fixed Point Types

1
The basic operations of a fixed point type include the operations involved in assignment, membership tests, qualification, the explicit conversion of values of other numeric types to the fixed point type, and the implicit conversion of values of the type universal_real to the type.

2
In addition, for every fixed point type or subtype T the basic operations include the attributes listed below. In this presentation T is referred to as being a subtype (the subtype T) for any property that depends on constraints imposed by T; other properties are stated in terms of the base type of T.

3
The first group of attributes yield characteristics of the subtype T. The attributes of this group are the attributes BASE (see 3.3.2), the attributes FIRST and LAST (see 3.5), the representation attribute SIZE (see 13.7.2) and the following attributes:

4 T'DELTAYields the value of the delta specified in the fixed accuracy definition for the subtype T. The value of this attribute is of the type universal_real.
5 T'MANTISSA   Yields the number of binary digits in the mantissa of model numbers of the subtype T. (This attribute yields the number B of section 3.5.9.) The value of this attribute is of the type universal_integer.
6 T'SMALLYields the smallest positive (nonzero) model number of the subtype T. The value of this attribute is of the type universal_real.
7 T'LARGEYields the largest positive model number of the subtype T. The value of this attribute is of the type universal_real.
8 T'FOREYields the minimum number of characters needed for the integer part of the decimal representation of any value of the subtype T, 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 two.) The value of this attribute is of the type universal_integer.
9 T'AFTYields the number of decimal digits needed after the point to accommodate the precision of the subtype T, unless the delta of the subtype T is greater than 0.1, in which case the attribute yields the value one. (T'AFT is the smallest positive integer N for which (10**N)*T'DELTA is greater than or equal to one.) The value of this attribute is of the type universal_integer.
10
The attributes of the second group include the following attributes which yield characteristics of the safe numbers:

11 T'SAFE_SMALLYields the smallest positive (nonzero) safe number of the base type of T. The value of this attribute is of the type universal_real.
12 T'SAFE_LARGEYields the largest positive safe number of the base type of T. The value of this attribute is of the type universal_real.
13
In addition, the attributes A'SIZE and A'ADDRESS are defined for an object A of a fixed point type (see 13.7.2). Finally, for each fixed point type or subtype T, there are the machine-dependent attributes T'MACHINE_ROUNDS and T'MACHINE_OVERFLOWS (see 13.7.3).

14
Besides the basic operations, the operations of a fixed point type include the relational operators, and the following predefined arithmetic operators: the binary and unary adding operators - and +, the multiplying operators * and /, and the operator abs.

15
The operations of a subtype are the corresponding operations of the type except for the following: assignment, membership tests, qualification, explicit conversion, and the attributes of the first group; the effects of these operations are redefined in terms of the subtype.

Notes:

16
The value of the attribute T'FORE depends only on the range of the subtype T. The value of the attribute T'AFT depends only on the value of T'DELTA. The following relations exist between attributes of a fixed point type:

T'LARGE = (2**T'MANTISSA - 1) * T'SMALL
T'SAFE_LARGE = T'BASE'LARGE
T'SAFE_SMALL = T'BASE'SMALL

17
References:

*
abs operator 4.5

*
abs operator 4.5.6

*
arithmetic operator 3.5.5

*
arithmetic operator 4.5

*
assignment 5.2

*
base type 3.3

*
basic operation 3.3.3

*
binary adding operator 4.5

*
binary adding operator 4.5.3

*
bound of a range 3.5

*
conversion 4.6

*
delta 3.5.9

*
fixed point type 3.5.9

*
membership test 4.5

*
membership test 4.5.2

*
model number 3.5.6

*
multiplying operator 4.5

*
multiplying operator 4.5.5

*
numeric type 3.5

*
object 3.2

*
operation 3.3

*
qualified expression 4.7

*
relational operator 4.5

*
relational operator 4.5.2

*
safe number 3.5.6

*
subtype 3.3

*
unary adding operator 4.5

*
unary adding operator 4.5.4

*
universal_integer type 3.5.4

*
universal_real type 3.5.6



[Home] [Prev] [Next] [Index]

documentation@rational.com
Copyright © 1993-2000, Rational Software Corporation. All rights reserved.