unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* test_9 (0.0/0.0, "+nan.0") fails on OpenBSD and FreeBSD
@ 2004-09-08 11:27 Andreas Vögele
  2004-09-08 14:31 ` Marius Vollmer
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Vögele @ 2004-09-08 11:27 UTC (permalink / raw)


The test test_9 (0.0/0.0, "+nan.0") in 
test-suite/standalone/test-conversion.c fails on OpenBSD and FreeBSD. 
The problem is that NaN may be negative or positive on these systems. 
The function real_eqv in libguile/eq.c, which uses memcmp to compares 
doubles, doesn't take this into account.

Here's output from gdb that shows the problem. The negative value -NaN 
of "x" is the value of "guile_NaN", which is calculated with the 
expression "guile_NaN = guile_Inf / guile_Inf" in numbers.c on BSD.  
The positive value NaN of "y" is the result of 0.0/0.0.

test_9 (val=NaN(0x8000000000000), result=0x3c00089e "+nan.0") at 
test-conversion.c:785
Breakpoint 3, real_eqv (x=-NaN(0x8000000000000), 
y=NaN(0x8000000000000)) at eq.c:61

Here's a version of real_eqv that works correctly on BSD:

static int
real_eqv (double x, double y)
{
  return !memcmp (&x, &y, sizeof(double)) || (x != x && y != y);
}

Since NaN != NaN, the expression "(x != x && y != y)" is true if "x" 
and "y" are both NaNs.



_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-09-08 14:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-08 11:27 test_9 (0.0/0.0, "+nan.0") fails on OpenBSD and FreeBSD Andreas Vögele
2004-09-08 14:31 ` Marius Vollmer

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).