**Submitter:**CFP group

**Submission Date:** 2021-06-06

**Document:** WG14 N2754

**Title:** N2754: DFP: Quantum exponent of NaN (version 2)

**Reference Documents:** N2596, N2642, IEEE 754-2019

Note: This is an update of N2642.

Summary: Q(x) is used to denote the quantum exponent of decimal floating-point x. Q(infinity) is defined as infinity. Some math functions make reference to Q(NAN). However, Q(NAN) is not defined in either C23 or IEEE 754-2019.

5.2.4.2.3 paragraph 9 says the preferred quantum exponent is specified by IEEE 754-2019 which has:

9.2.2 Preferred exponents:

The preferred exponent for operations in sub-clause 9.2 is 0, except for the following: ...

The table of Preferred quantum exponents in paragraph 10 of 5.2.4.2.3 makes reference to Q(x) and preferred quantum exponent of the result.

There are five cases where a NaN operand does not produce a NaN result for math functions. While the result's value is defined, the quantum exponent of that result is not well defined -- mainly because Q(NAN) is not defined.

- compoundn(NAN,0) -- F.10.4.2 says value is 1. The table in 5.2.4.2.3 says its quantum exponent is floor(0*min(0,Q(NAN))).
- hypot(+/-INFINITY,NAN) -- F.10.4.4 says value is +INFINITY. The table in 5.2.4.2.3 says its quantum exponent is min(Q(+/-INFINITY),Q(NAN)).
- pow(1,NAN) -- F.10.4.5 says value is 1. The table in 5.2.4.2.3 says its quantum exponent is floor(NAN*Q(1)).
- pow(NAN,0) -- F.10.4.5 says value is 1. The table in 5.2.4.2.3 says its quantum exponent is floor(0*Q(NAN)).
- pown(NAN,0) -- F.10.4.6 says value is 1. The table in 5.2.4.2.3 says its quantum exponent is floor(0*Q(NAN)).

There are many cases where an infinity operand does not produce an infinity result for math functions. While the result's value is defined, the quantum exponent of that result is sometimes not well defined -- mainly because zero*infinity is not defined.

- pow(1e0,infinity) -- F.10.4.5 says value is 1. The table in 5.2.4.2.3 says its quantum exponent is floor(infinity*Q(1e0)) -- which is floor(infinity*zero).
- pow(infinity,0) -- F.10.4.5 says value is 1. The table in 5.2.4.2.3 says its quantum exponent is floor(0*Q(infinity)) -- which is floor(zero*infinity).
- pown(infinity,0) -- F.10.4.6 says value is 1. The table in 5.2.4.2.3 says its quantum exponent is floor(0*Q(infinity)) -- which is floor(zero*infinity).

These appear to be defects in IEEE 754-2019 as Q(NAN) is not defined, nor is Q(zero*infinity) defined.

Suggested changes to C23: Change 5.2.4.2.3, paragraph 10 from:

The following table shows, for each operation delivering a result in decimal floating-point format, how the preferred quantum exponents of the operands, Q(x), Q(y), etc., determine the preferred quantum exponent of the operation result.to

The following table shows, for each operation delivering a result in decimal floating-point format, how the preferred quantum exponents of the operands, Q(x), Q(y), etc., determine the preferred quantum exponent of the operation result~~.~~, provided the table formula is defined for the arguments. For the cases where the formula is undefined and the function result is +/-infinity, the preferred quantum exponent is immaterial because the quantum exponent of +/- infinity is defined to be infinity. For the other cases where the formula is undefined and the function result is finite, the preferred quantum exponent is unspecified.*)*) Although unspecified in IEC 60559, a preferred quantum exponent of 0 for these cases would be a reasonable implementation choice.