Chapter 3
Ada Language Reference
3-36
ni.com
•
Floating-Point Textual Representation
—The values generated from
a stand-alone simulation are converted to a textual (ASCII)
representation. That representation in textual form might not quite be
as accurate as possible. That is, the last few digits in the mantissa might
be different than the simulator’s textual representation. There is no
solution other than to upgrade and/or change to a compiler that
converts floating-point numbers to a textual form more accurately.
•
32-bit Computations
—Ada specifies that all fixed-point calculations
are exact. However, for 32-bit multiplication and division, there might
be differences in the algorithm used by the Ada compiler vendor.
These differences could affect accuracy when compared against the
SystemBuild Simulator. The simulator uses a 64-bit extended integer
calculation for 32-bit multiplication and division. Therefore,
differences could be a result of 32-bit algorithm differences. It might
be necessary to implement your own 32-bit multiplication or division
algorithm if the error in the predefined Ada algorithm is too large.
No-Op Conversion Function
The purpose of the so-called no-op conversion function is to provide a hint
to the compiler to select the proper overloaded operator. Without such a
hint, there can be situations where the selection of the appropriate
overloaded operator is ambiguous. Simple expressions of the form
a = b
op c
cannot be ambiguous. However, if
a
,
b
, or
c
is a complex
subexpression, like
a = b
op c op d
, it is possible that there is
insufficient type information to resolve which operator is to be used.
The code in Example 3-6 illustrates the problem and solution.
Table 3-11.
Possible Midpoint Round Modes
Mode
INTEGER(5.5)
INTEGER(–6.5)
Toward 0
5
–6
Away from 0
6
–7
Positive Infinity
6
–6
Negative Infinity
5
–7
To Odd
5
–7
To Even
6
–6