[前][次][番号順一覧][スレッド一覧]

ruby-changes:43616

From: nobu <ko1@a...>
Date: Fri, 15 Jul 2016 17:09:04 +0900 (JST)
Subject: [ruby-changes:43616] nobu:r55689 (trunk): util.c: do not underflow

nobu	2016-07-15 17:08:59 +0900 (Fri, 15 Jul 2016)

  New Revision: 55689

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55689

  Log:
    util.c: do not underflow
    
    * util.c (ruby_strtod): do not underflow only by preceeding zeros,
      which may be canceled out by the exponent.
      http://twitter.com/kazuho/status/753829998767714305

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_literal.rb
    trunk/util.c
Index: util.c
===================================================================
--- util.c	(revision 55688)
+++ util.c	(revision 55689)
@@ -2145,7 +2145,7 @@ break2: https://github.com/ruby/ruby/blob/trunk/util.c#L2145
         for (; c >= '0' && c <= '9'; c = *++s) {
 have_dig:
             nz++;
-            if (nf > DBL_DIG * 4) continue;
+            if (nd > DBL_DIG * 4) continue;
             if (c -= '0') {
                 nf += nz;
                 for (i = 1; i < nz; i++)
Index: test/ruby/test_literal.rb
===================================================================
--- test/ruby/test_literal.rb	(revision 55688)
+++ test/ruby/test_literal.rb	(revision 55689)
@@ -493,6 +493,7 @@ class TestRubyLiteral < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_literal.rb#L493
         }
       }
     }
+    assert_equal(100.0, 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100e100)
   end
 
   def test_symbol_list
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55688)
+++ ChangeLog	(revision 55689)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jul 15 17:08:57 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* util.c (ruby_strtod): do not underflow only by preceeding zeros,
+	  which may be canceled out by the exponent.
+	  http://twitter.com/kazuho/status/753829998767714305
+
 Fri Jul 15 15:32:13 2016  NAKAMURA Usaku  <usa@r...>
 
 	* time.c (time_arg): it seems that this function sometimes causes SEGV

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]