bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

test_9 (0.0/0.0, "+nan.0") fails on OpenBSD and FreeBSD


From: Andreas Vögele
Subject: test_9 (0.0/0.0, "+nan.0") fails on OpenBSD and FreeBSD
Date: Wed, 8 Sep 2004 13:27:53 +0200

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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]