IEEE Real Number Format (NM) (new) [ Introduction to MPE XL for MPE V Programmers Migration Guide ] MPE/iX 5.0 Documentation
Introduction to MPE XL for MPE V Programmers Migration Guide
IEEE Real Number Format (NM)
(new)
MPE V/E uses HP3000 format for storing floating-point real numbers. The
MPE XL operating system uses two formats: HP 3000 and IEEE, the standard
set by the the American National Standards Institute and Institute of
Electrical and Electronics Engineers (ANSI/IEEE Std 754-1985). In MPE
XL, HP3000 is the default storage format for CM, and IEEE is the default
for NM. Table 10-5 shows a summary of their characteristics.
Table 10-5. IEEE and HP 3000 Format Comparison
-----------------------------------------------------------------------------------------------
| | | |
| | IEEE | HP 3000 |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| Single precision: | | |
| | | |
| |
| | | |
| Accuracy | 7.2 | 6.9 |
| (in decimal digits) | | |
| | | |
| |
| | | |
| Range | -3.4E38 to -1.4E-45, 0, | -1.2E77 to -8.6E-78, 0, |
| | +1.4E-45 to +3.4E38 | +8.6E-78 to +1.2E77 |
| | | |
| |
| | | |
| Double precision: | | |
| | | |
| |
| | | |
| Accuracy | 15.9 | 16.5 |
| (in decimal digits) | | |
| | | |
| |
| | | |
| Range | -1.8E308 to -4.9E-324, 0, | -1.2E77 to -8.6E-78, 0, |
| | +4.9E-324 to +1.8E308 | +8.6E-78 to +1.2E77 |
| | | |
-----------------------------------------------------------------------------------------------
NOTE Values in this table are rounded.
Real Number Bit Format
When stored in memory, real numbers are aligned on word boundaries. MPE
V/E and MPE XL CM use a 16-bit word format; MPE XL NM uses a 32-bit word
format.
In MPE V/E and in MPE XL, real numbers are represented in memory by 32
bits (single-precision) or 64 bits (double-precision) format.
Represent a floating-point zero by setting all the bits to zero (0).
Represent other numbers as binary numbers with three fields:
* Sign. The sign field is the first bit of the first word. A value of
0 in this position indicates the number is positive; a value of 1,
that it is negative.
* Exponent. The exponent field starts on bit 1. Notice that this
field is 9 bits long on MPE V/E and MPE XL CM, but on MPE XL NM it is
8 bits long for single-precision numbers and 11 bits long for
double-precision numbers.
* Mantissa. The mantissa field begins after the exponent field and
goes to the end of the word. Its length varies, depending on format
and precision. Data is stored as a binary number of the form 1.xxx,
where the 1 and binary point of the mantissa are not actually stored,
but assumed to be present.
Figure 10-2 and Figure 10-3 show a comparison of the MPE V/E and MPE XL
internal representation of single-precision and double-precision real
numbers.
Figure 10-2. MPE V/E and MPE XL Single-Precision Real Number Comparison
Figure 10-3. MPE V/E and MPE XL Double-Precision Real Number Comparison
Converting Numbers Between Formats
You can use the MPE XL intrinsic HPFCONVERT in a program to convert
individual numbers between formats as necessary.
You can also force a floating-point number format with the compiler
options available in MPE XL. Choosing the HP3000_16 compiler option will
force the 16-bit word data alignment and the HP3000 format for real
number storage compatable with MPE V/E and MPE XL CM. Specifying the
HP3000_32 compiler option will align data with 32-bit words and store
real numbers in IEEE format, which are the defaults for MPE XL NM.
As Table 10-5 shows, IEEE and HP3000 formats have different accuracies
and ranges for single-precision and double-precision real numbers.
Conversion Exception Conditions. Table 10-6 shows the valid
floating-point conversion procedures and indicates any exception to
accurate conversion that can occur. These exception conditions are
described in the subsections below.
Table 10-6. Floating-point Conversion Procedures
----------------------------------------------------------------------------------------------
| | | |
| Source format | Destination format | Exception Conditions |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| CM32 | CM32 | - |
| | | |
| CM32 | CM64 | - |
| | | |
| CM32 | NM32 | OU |
| | | |
| CM32 | NM64 | - |
| | | |
| CM64 | CM32 | O |
| | | |
| CM64 | CM64 | - |
| | | |
| CM64 | NM32 | OUX |
| | | |
| CM64 | NM64 | X |
| | | |
| NM32 | CM32 | IO |
| | | |
| NM32 | CM64 | IO |
| | | |
| NM32 | NM32 | - |
| | | |
| NM32 | NM64 | I |
| | | |
| NM64 | CM32 | IOU |
| | | |
| NM64 | CM64 | IOU |
| | | |
| NM64 | NM32 | IOUX |
| | | |
| NM64 | NM64 | - |
| | | |
| NM128 | CM32 | IOU |
| | | |
| NM128 | CM64 | IOU |
| | | |
| NM128 | NM32 | IOUX |
| | | |
| NM128 | NM64 | IOUX |
| | | |
| NM128 | NM128 | - |
| | | |
| | | |
----------------------------------------------------------------------------------------------
| |
| Where: |
| |
| CM32 is HP 3000 32-bit real | I is Invalid |
| | |
| CM64 is HP 3000 64-bit real | O is Overflow |
| | |
| NM32 is IEEE 32-bit real | U is Underflow |
| | |
| NM64 is IEEE 64-bit real | X is Inexact |
| | |
----------------------------------------------------------------------------------------------
Converting CM to NM
When converting CM to NM, the following exceptions could occur:
Inexact. Inexact occurs when the rounded result is not exact or an
underflow or overflow occurs. In this case, the result is restricted due
to limitations in exponent range and precision.
Invalid Operation (NaN). Not a Number (NaN), is a symbolic entity
encoded in IEEE floating-point format. Signaling NaNs are the values
assigned to uninitialized variables. Quiet NaNs are propagated by
invalid or unavailable data and/or results and provide diagnostic
information.
Any operation that involves a signaling NaN or invalid operation, returns
a quiet NaN as the result when no trap occurs and a floating-point result
is to be delivered. An operation using one or two quiet NaNs as input
signals no exception; however, if a floating-point result is to be
delivered, a quiet NaN is returned that is the same as one of the input
NaNs.
NOTE NaNs are identified by the following: the binary coded exponent
field contains all 1s and the fraction field is not equal to zero.
(This differs from the IEEE representation for infinity where the
binary exponent field is all 1s, but the fraction field is all 0s.)
Overflow. Overflow is signaled when the destination format's largest
finite number is exceeded in magnitude by the rounded floating-point
result that would occur if the exponent range were unbounded. The result
is determined by the rounding mode and the sign of the intermediate
result as follows:
* Round to nearest carries all overflows to infinity with the sign of
the intermediate result.
* Round to zero carries all overflows to the format's largest finite
number with the sign of the intermediate result.
* Round toward negative infinity carries the positive overflows to the
format's largest finite number and carries negative overflows to
negative infinity.
* Round toward positive infinity carries the negative overflows to the
format's most negative finite number and carries positive overflows
to positive infinity.
Underflow. Underflow is signaled on one of two correlated events; the
first is the creation of a tiny nonzero result between the smallest
nonzero numbers, which may cause an overflow if used in division. The
second is an extreme loss of accuracy during the approximation of tiny
numbers by denormalized numbers. Tininess is detected after rounding.
Loss of accuracy is detected as an inexact result.
Converting NM to CM
Converting from NM to CM could cause the following exceptions to occur:
Invalid Operation (NaN). Invalid operation is signaled when the source
is a signaling or a quiet NaN. The result is the destination format's
largest finite number with the sign of the source.
Overflow. Overflow always occurs when an attempt is made to convert
infinities (which are represented only in IEEE) to CM formats. When an
overflow occurs, the returned result is the destination format's largest
finite number with the sign of the source.
Underflow. Underflow is signaled when the magnitude of the source number
(treated as if the exponent range and precision are unbounded) is less
than half the magnitude of the destination format's smallest nonzero
number. The result is zero.
MPE/iX 5.0 Documentation