gauche (0.9.1-5.1) 18_number.patch

Summary

 src/number.c    |    1 +
 test/number.scm |    6 ++++++
 2 files changed, 7 insertions(+)

    
download this patch

Patch contents

Description: backport of number 2.2250738585072012e-308 parsing fix
 For details see thread "number 2.2250738585072012e-308" on gauche mailing list.
 Message-Id: <20110202.041755.1100784484505157070.shiro@lava.net>
 and svn r7363
Author: Shiro Kawai <shiro@lava.net>
Last-Update: 2011-02-14

Index: gauche-0.9.1/src/number.c
===================================================================
--- gauche-0.9.1.orig/src/number.c	2010-11-24 18:00:48.000000000 +0900
+++ gauche-0.9.1/src/number.c	2011-02-14 11:35:01.000000000 +0900
@@ -3543,6 +3543,7 @@
         case -1: /* d2 < y */
             if (Scm_NumCmp(m, SCM_2_52) == 0
                 && sign_d < 0
+                && k > -1074
                 && Scm_NumCmp(Scm_Ash(d2, 1), y) > 0) {
                 goto prevfloat;
             } else {
Index: gauche-0.9.1/test/number.scm
===================================================================
--- gauche-0.9.1.orig/test/number.scm	2010-07-01 11:30:44.000000000 +0900
+++ gauche-0.9.1/test/number.scm	2011-02-14 11:35:01.000000000 +0900
@@ -270,6 +270,12 @@
 (test* "flonum reader (minimum denormalized number -5.0e-324)" #t
        (let1 x (- (expt 2.0 -1074))
          (= x (string->number (number->string x)))))
+
+;; This hanged in 0.9.1.  See Jens Thiele's message in gauche-devel
+;; in Feb. 2011.
+(test* "flonum reader (minimum normalized number)" #t
+       (= (expt 2.0 (- 52 1074))
+          (string->number "2.2250738585072012e-308")))
        
 
 (test* "padding" '(10.0 #t) (flonum-test '1#))