* bug#14865: flmax and flmin do not handle +nan.0 correctly
@ 2013-07-15 11:11 Göran Weinholt
2013-07-16 9:27 ` Mark H Weaver
0 siblings, 1 reply; 2+ messages in thread
From: Göran Weinholt @ 2013-07-15 11:11 UTC (permalink / raw)
To: 14865
[-- Attachment #1: Type: text/plain, Size: 507 bytes --]
Hello schemers,
the flmax and flmin procedures from (rnrs) do not handle +nan.0
correctly:
scheme@(guile-user)> (import (rnrs))
scheme@(guile-user)> (flmax +inf.0 +nan.0)
$1 = +inf.0
scheme@(guile-user)> (flmin -inf.0 +nan.0)
$2 = -inf.0
The result should be +nan.0. From r6rs-lib: "They always return a NaN
when one or more of the arguments is a NaN." Tested with
2.0.9.22-7e816-dirty.
Regards,
--
Göran Weinholt <goran@weinholt.se>
It's a beautiful day.
Don't let it get away.
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#14865: flmax and flmin do not handle +nan.0 correctly
2013-07-15 11:11 bug#14865: flmax and flmin do not handle +nan.0 correctly Göran Weinholt
@ 2013-07-16 9:27 ` Mark H Weaver
0 siblings, 0 replies; 2+ messages in thread
From: Mark H Weaver @ 2013-07-16 9:27 UTC (permalink / raw)
To: Göran Weinholt; +Cc: 14865-done
Göran Weinholt <goran@weinholt.se> writes:
> the flmax and flmin procedures from (rnrs) do not handle +nan.0
> correctly:
>
> scheme@(guile-user)> (import (rnrs))
> scheme@(guile-user)> (flmax +inf.0 +nan.0)
> $1 = +inf.0
> scheme@(guile-user)> (flmin -inf.0 +nan.0)
> $2 = -inf.0
>
> The result should be +nan.0. From r6rs-lib: "They always return a NaN
> when one or more of the arguments is a NaN."
Indeed. I had actually carefully implemented 'min' and 'max' according
to R6RS section 11.7.4 (Numerical operations), which states:
For any real number object x:
(max +inf.0 x) => +inf.0
(min -inf.0 x) => -inf.0
and section 3.5 states that NaNs are real number objects.
At first I was baffled by the inconsistency between min/max and
flmin/flmax, but now I see that the R6RS errata corrected this:
The examples for min and max involving infinities should be prefixed by:
"For any real number object x /that is not a NaN/:"
Fixed in b4c55c9ccedd47c16007b590f064ef3bd67565aa.
Thanks!
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-07-16 9:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-15 11:11 bug#14865: flmax and flmin do not handle +nan.0 correctly Göran Weinholt
2013-07-16 9:27 ` Mark H Weaver
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).