Bug 6779 - remainder() wrongly gives a domain error for (NaN, 0)
Summary: remainder() wrongly gives a domain error for (NaN, 0)
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: math (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Andreas Jaeger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-30 11:14 UTC by Michael Kerrisk
Modified: 2016-11-19 09:26 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
test program (2.74 KB, text/plain)
2008-07-31 08:34 UTC, Michael Kerrisk
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Kerrisk 2008-07-30 11:14:27 UTC
The posix reaminder() spec says:

==
If x or y is NaN, a NaN shall be returned.

If x is infinite or y is 0 and the other is non-NaN, a domain error shall occur,
and either a NaN (if supported), or an implementation-defined value shall be
returned
==

On glibc 2.8, remainder(NaN, 0) gives a domain error (EDOM, FE_INVALID).  As per
the above spec, it should return a NaN without error.
Comment 1 Michael Kerrisk 2008-07-31 08:34:57 UTC
Created attachment 2844 [details]
test program

Sample run showing problem:

$ /tmp/mt_remainder nan 0
errno == EDOM
fetestexcept() says:  FE_INVALID
remainder(nan,0.00000000000000000e+00)=nan
EDOM FE_INVALID nan
Comment 2 Andreas Jaeger 2011-09-29 09:33:37 UTC
Thanks, patch send to libc-alpha mailinglist.
Comment 3 Ulrich Drepper 2011-10-07 19:16:05 UTC
I've checked in the patch.
Comment 4 Michael Kerrisk 2016-11-19 09:26:03 UTC
Documented for man-pages-4.09.