Submitter:CFP group
Submission Date: 2021-??-??
Document: WG14 N27??
Title: N27??: 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.

Since both NaN and infinity are not supported by all implementations, any update to the standard should go in Annex F, not the main body of the standard.

Proposal

Add to F.10.7.3 The remquo functions, paragraph 1:

If a NaN is returned, the value stored in the object pointed to by quo is unspecified.