summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-12 07:25:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-12 07:25:48 +0000
commitd2a68945e6c20cf5e68ef27387b31ac102fd493f (patch)
treeba76980b037addf2b97144d5727b6e251b2e8664 /numeric.c
parent16ea63ad692df3aa038178e57cb907df5d14a11b (diff)
* numeric.c (flo_to_s): exponent needs 2 digits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/numeric.c b/numeric.c
index 23c54800ee..d6dd1c4a5c 100644
--- a/numeric.c
+++ b/numeric.c
@@ -585,10 +585,9 @@ flo_to_s(VALUE flt)
}
else if (decpt - digs < float_dig) {
long len;
- char *ptr;
rb_str_cat(s, buf, digs);
- rb_str_resize(s, (len = RSTRING_LEN(s)) + decpt - digs);
- memset(RSTRING_PTR(s) + len, '0', decpt - digs);
+ rb_str_resize(s, (len = RSTRING_LEN(s)) + decpt - digs + 2);
+ if (decpt > digs) memset(RSTRING_PTR(s) + len, '0', decpt - digs);
rb_str_cat(s, ".0", 2);
}
else {
@@ -615,7 +614,7 @@ flo_to_s(VALUE flt)
}
buf[1] = '.';
rb_str_cat(s, buf, digs + 1);
- rb_str_catf(s, "e%+d", decpt - 1);
+ rb_str_catf(s, "e%+03d", decpt - 1);
}
return s;
}