guile-devel
[Top][All Lists]
Advanced

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

Re: guile-core-20020426 and IEEE 754 arithmetic


From: John W. Eaton
Subject: Re: guile-core-20020426 and IEEE 754 arithmetic
Date: Thu, 16 May 2002 10:17:47 -0500

On 16-May-2002, Nelson H. F. Beebe <address@hidden> wrote:

| guile-core-20020426 (1.5.6):
|       guile> -0.0
|       0.0                                     !WRONG
|       guile> (- 0.0)
|       0.0                                     !WRONG
|       guile> (/ -1 (/ 1.0 0.0))
|       0.0                                     !WRONG

With the following patch, guile produces

        guile> -0.0
        0.0
        guile> (- 0.0)
        -0.0
        guile> (/ -1 (/ 1.0 0.0))
        -0.0

It looks like guile is dropping the sign on input.  I would have tried
to fix that problem too, but I couldn't figure out where the string ->
double conversion takes place.

jwe



ChangeLog:

2002-05-16  John W. Eaton  <address@hidden>

        * configure.in (AC_CHECK_FUNCS): Check for copysign.

libguile/ChangeLog:

2002-05-16  John W. Eaton  <address@hidden>

        * numbers.c (idbl2str): Don't omit sign when printing negative zero.



--- configure.in        2002/05/16 15:04:05     1.1
+++ configure.in        2002/05/16 15:03:54
@@ -505,7 +505,7 @@
 
 AC_CHECK_HEADERS(floatingpoint.h ieeefp.h nan.h)
 
-AC_CHECK_FUNCS(finite isinf isnan)
+AC_CHECK_FUNCS(finite isinf isnan copysign)
 
 # When testing for the presence of alloca, we need to add alloca.o
 # explicitly to LIBOBJS to make sure that it is translated to

--- libguile/numbers.c  2002/05/16 15:01:34     1.1
+++ libguile/numbers.c  2002/05/16 15:02:45
@@ -2076,7 +2076,16 @@
   int exp = 0;
 
   if (f == 0.0)
-    goto zero;                 /*{a[0]='0'; a[1]='.'; a[2]='0'; return 3;} */
+    {
+#ifdef HAVE_COPYSIGN
+      double sgn = copysign (1.0, f);
+
+      if (sgn < 0.0)
+       a[ch++] = '-';
+#endif
+
+      goto zero;       /*{a[0]='0'; a[1]='.'; a[2]='0'; return 3;} */
+    }
 
   if (xisinf (f))
     {



reply via email to

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