Submitter:CFP group
Submission Date: 2021-08-01
Document: WG14 N2790
Title: N2790: remquo()
Reference Documents:WG14 N2723, SC22WG14.19482

Summary: The Austin Group Liaison Statement raised an issue:

Bug 713: in remquo quo should be unspecified when the result is NaN

and asked WG14 if that requirement makes sense and should it be added to C23.

Discussion

remquo(x, y, &quo) computes both the remainder and (the low order bits of) the quotient of x/y. The function returns the floating-point remainder and stores the quotient in the int pointed to by quo.

7.12.10.3 The remquo functions paragraph 3, has (in part):

If y is zero, the value stored in the object pointed to by quo is unspecified and ...

However, there are three other cases where the remainder and quotient have no mathematical value:

While the function returns a floating-point NaN for those three cases (F.10#13, F.10.7.3, F.10.7.2), the standard is silent on what should happen to *quo. In those case, *quo should also be a NaN, but since it is an int, it cannot hold the value NaN.

Cases like this for NaNs and infinities, which are values outside the unextended floating-point model (4.2.4.2.2), are generally covered in Annex F instead of 7.12 (unless the treatment of NaNs or infinites is integral to the behavior of the function or macro).

Proposal

Change F.10.7.3 The remquo functions from:

[1] The remquo functions follow the specifications for the remainder functions. They have no further specifications special to IEC 60559 implementations.
[2] When subnormal results are supported, the returned value is exact and is independent of the current rounding direction mode.
to:
[1] The remquo functions follow the specifications for the remainder functions. They have no further specifications special to IEC 60559 implementations.
[2] If a NaN is returned, the value stored in the object pointed to by quo is unspecified.
[2][3] When subnormal results are supported, the returned value is exact and is independent of the current rounding direction mode.