guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] GNU Guile branch, master, updated. release_1-9-0-36-g40f


From: Neil Jerram
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-0-36-g40f8921
Date: Wed, 01 Jul 2009 18:46:48 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=40f892156acba9cac990d2a53333fc41cefcd507

The branch, master has been updated
       via  40f892156acba9cac990d2a53333fc41cefcd507 (commit)
      from  dd57ddd5ede6d3d9a736b2b48455fbd87da51e3a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 40f892156acba9cac990d2a53333fc41cefcd507
Author: Neil Jerram <address@hidden>
Date:   Wed Jul 1 01:39:24 2009 +0100

    Read complex numbers where both parts are inexact decimals
    
    Thanks to Bill Schottstaedt for reporting this problem!
    
    * libguile/numbers.c (mem2ureal): Don't be misled by *p_exactness
      being INEXACT on entry (as is possible when reading a complex
      number): use local exactness variable x which starts as EXACT.
      Call mem2decimal_from_point () with &x instead of p_exactness.
    
    * test-suite/tests/numbers.test ("string->number"): Add complex number
      tests suggested by Bill.

-----------------------------------------------------------------------

Summary of changes:
 NEWS                          |    1 +
 libguile/numbers.c            |   19 +++++++++++++------
 test-suite/tests/numbers.test |    9 ++++++++-
 3 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/NEWS b/NEWS
index 593d6c2..a33c490 100644
--- a/NEWS
+++ b/NEWS
@@ -560,6 +560,7 @@ Changes in 1.8.7 (since 1.8.6)
 ** With GCC, always compile with `-mieee' on `alpha*' and `sh*'
 ** Better diagnose broken `(strftime "%z" ...)' in `time.test' (bug #24130)
 ** Fix parsing of SRFI-88/postfix keywords longer than 128 characters
+** Fix reading of complex numbers where both parts are inexact decimals
 
 ** Allow @ macro to work with (ice-9 syncase)
 
diff --git a/libguile/numbers.c b/libguile/numbers.c
index 83b3f7c..c7e0981 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -2733,6 +2733,10 @@ mem2ureal (const char* mem, size_t len, unsigned int 
*p_idx,
   unsigned int idx = *p_idx;
   SCM result;
 
+  /* Start off believing that the number will be exact.  This changes
+     to INEXACT if we see a decimal point or a hash. */
+  enum t_exactness x = EXACT;
+
   if (idx == len)
     return SCM_BOOL_F;
 
@@ -2744,8 +2748,6 @@ mem2ureal (const char* mem, size_t len, unsigned int 
*p_idx,
 
   if (idx+4 < len && !strncmp (mem+idx, "nan.", 4))
     {
-      enum t_exactness x = EXACT;
-
       /* Cobble up the fractional part.  We might want to set the
         NaN's mantissa from it. */
       idx += 4;
@@ -2764,11 +2766,10 @@ mem2ureal (const char* mem, size_t len, unsigned int 
*p_idx,
        return SCM_BOOL_F;
       else
        result = mem2decimal_from_point (SCM_I_MAKINUM (0), mem, len,
-                                        p_idx, p_exactness);
+                                        p_idx, &x);
     }
   else
     {
-      enum t_exactness x = EXACT;
       SCM uinteger;
 
       uinteger = mem2uinteger (mem, len, &idx, radix, &x);
@@ -2800,10 +2801,16 @@ mem2ureal (const char* mem, size_t len, unsigned int 
*p_idx,
        result = uinteger;
 
       *p_idx = idx;
-      if (x == INEXACT)
-       *p_exactness = x;
     }
 
+  /* Update *p_exactness if the number just read was inexact.  This is
+     important for complex numbers, so that a complex number is
+     treated as inexact overall if either its real or imaginary part
+     is inexact.
+  */
+  if (x == INEXACT)
+    *p_exactness = x;
+
   /* When returning an inexact zero, make sure it is represented as a
      floating point value so that we can change its sign. 
   */
diff --git a/test-suite/tests/numbers.test b/test-suite/tests/numbers.test
index 57e2f9b..4a9476a 100644
--- a/test-suite/tests/numbers.test
+++ b/test-suite/tests/numbers.test
@@ -1365,7 +1365,14 @@
                 ("address@hidden" 1.0) ("address@hidden" 1.0) 
("address@hidden" 1.0)
                 ("2+3i" ,(+ 2 (* 3 +i))) ("4-5i" ,(- 4 (* 5 +i)))
                 ("1+i" 1+1i) ("1-i" 1-1i) ("+1i" 0+1i) ("-1i" 0-1i)
-                ("+i" +1i) ("-i" -1i)))
+                ("+i" +1i) ("-i" -1i)
+               ("1.0+.1i" 1.0+0.1i)
+               ("1.0-.1i" 1.0-0.1i)
+               (".1+.0i" 0.1)
+               ("1.+.0i" 1.0)
+               (".1+.1i" 0.1+0.1i)
+               ("1e1+.1i" 10+0.1i)
+               ))
     #t)
 
   (pass-if-exception "exponent too big"


hooks/post-receive
-- 
GNU Guile




reply via email to

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