7-57
FLOATING-POINT UNIT
7.8.6.Inexact Result (Precision) Exception (#P)
The inexact result exception (also called the precision exception) occurs if the result of an oper-
ation is not exactly representable in the destination format. For example, the fraction 1/3 cannot
be precisely represented in binary form. This exception occurs frequently and indicates that
some (normally acceptable) accuracy has been lost. The exception is supported for applications
that need to perform exact arithmetic only. Because the rounded result is generally satisfactory
for most applications, this exception is commonly masked. Note that the transcendental instruc-
tions [FSIN, FCOS, FSINCOS, FPTAN, FPATAN, F2XM1, FYL2X, and FYL2XP1] by nature
produce inexact results.
The inexact result exception flag (PE) is bit 5 of the FPU status word, and the mask bit (PM) is
bit 5 of the FPU control word.
If the inexact result exception is masked when an inexact result condition occurs and a numeric
overflow or underflow condition has not occurred, the FPU sets the PE flag and stores the
rounded result in the destination operand. The current rounding mode determines the method
used to round the result (refer to Section 7.3.4.3., Rounding Control Field). The C1 (round-
up) bit in the FPU status word indicates whether the inexact result was rounded up (C1 is set) or
not rounded up (C1 is cleared). In the not rounded up case, the least-significant bits of the
inexact result are truncated so that the result fits in the destination format.
If the inexact result exception is not masked when an inexact result occurs and numeric overflow
or underflow has not occurred, the FPU performs the same operation described in the previous
paragraph and, in addition, invokes a software exception handler (refer to Section 7.7.3., Soft-
ware Exception Handling).
If an inexact result occurs in conjunction with numeric overflow or underflow, one of the
following operations is carried out:
If an inexact result occurs along with masked overflow or underflow, the OE or UE flag
and the PE flag are set and the result is stored as described for the overflow or underflow
exceptions (refer to Section 7.8.4., Numeric Overflow Exception (#O) or Section 7.8.5.,
Numeric Underflow Exception (#U)). If the inexact result exception is unmasked, the
FPU also invokes the software exception handler.
If an inexact result occurs along with unmasked overflow or underflow and the destination
operand is a register, the OE or UE flag and the PE flag are set, the result is stored as
described for the overflow or underflow exceptions, and the software exception handler is
invoked.
If an inexact result occurs along with unmasked overflow or underflow and the destination
operand is a memory location, the inexact result condition is ignored.
7.8.7.Exception Priority
The processor handles exceptions according to a predetermined precedence. When an instruc-
tion generates two or more exception conditions, the exception precedence sometimes results in
the higher-priority exception being handled and the lower-priority exceptions being ignored. For