summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-19 14:14:52 (GMT)
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-19 14:14:52 (GMT)
commit7be47caa8816c50f9791e3636852aaa80cb99b47 (patch)
treea47c7cd3d355dc683f727d2905ea5d3d6281e9c5 /util.c
parenta4d51619e9c3a9d03a0445cfd4947ec811754e52 (diff)
Merge latest dtoa.c [Bug #13545]
Apply some part of http://www.netlib.org/fp/dtoa.c with my eyes... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'util.c')
-rw-r--r--util.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/util.c b/util.c
index f5ad0ec..3ebb2fe 100644
--- a/util.c
+++ b/util.c
@@ -2117,7 +2117,7 @@ break2:
for (nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)
if (nd < 9)
y = 10*y + c - '0';
- else if (nd < 16)
+ else if (nd < DBL_DIG + 2)
z = 10*z + c - '0';
nd0 = nd;
#ifdef USE_LOCALE
@@ -2157,17 +2157,19 @@ break2:
for (; c >= '0' && c <= '9'; c = *++s) {
have_dig:
nz++;
- if (nd > DBL_DIG * 4) continue;
+ if (nd > DBL_DIG * 4) {
+ continue;
+ }
if (c -= '0') {
nf += nz;
for (i = 1; i < nz; i++)
if (nd++ < 9)
y *= 10;
- else if (nd <= DBL_DIG + 1)
+ else if (nd <= DBL_DIG + 2)
z *= 10;
if (nd++ < 9)
y = 10*y + c;
- else if (nd <= DBL_DIG + 1)
+ else if (nd <= DBL_DIG + 2)
z = 10*z + c;
nz = 0;
}
@@ -2255,7 +2257,7 @@ ret0:
if (!nd0)
nd0 = nd;
- k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1;
+ k = nd < DBL_DIG + 2 ? nd : DBL_DIG + 2;
dval(rv) = y;
if (k > 9) {
#ifdef SET_INEXACT