* 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
This commit is contained in:
nobu 2010-05-12 07:25:48 +00:00
parent 16ea63ad69
commit d2a68945e6
2 changed files with 7 additions and 4 deletions

View File

@ -1,3 +1,7 @@
Wed May 12 16:25:46 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (flo_to_s): exponent needs 2 digits.
Wed May 12 16:02:43 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> Wed May 12 16:02:43 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (flo_to_s): fill lower zeros. * numeric.c (flo_to_s): fill lower zeros.

View File

@ -585,10 +585,9 @@ flo_to_s(VALUE flt)
} }
else if (decpt - digs < float_dig) { else if (decpt - digs < float_dig) {
long len; long len;
char *ptr;
rb_str_cat(s, buf, digs); rb_str_cat(s, buf, digs);
rb_str_resize(s, (len = RSTRING_LEN(s)) + decpt - digs); rb_str_resize(s, (len = RSTRING_LEN(s)) + decpt - digs + 2);
memset(RSTRING_PTR(s) + len, '0', decpt - digs); if (decpt > digs) memset(RSTRING_PTR(s) + len, '0', decpt - digs);
rb_str_cat(s, ".0", 2); rb_str_cat(s, ".0", 2);
} }
else { else {
@ -615,7 +614,7 @@ flo_to_s(VALUE flt)
} }
buf[1] = '.'; buf[1] = '.';
rb_str_cat(s, buf, digs + 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; return s;
} }