1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* numeric.c (flo_to_s): fixed broken output including nuls.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-05-12 07:43:14 +00:00
parent d2a68945e6
commit d80a859d98
2 changed files with 11 additions and 2 deletions

View file

@ -1,3 +1,7 @@
Wed May 12 16:43:12 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (flo_to_s): fixed broken output including nuls.
Wed May 12 16:25:46 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> Wed May 12 16:25:46 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (flo_to_s): exponent needs 2 digits. * numeric.c (flo_to_s): exponent needs 2 digits.

View file

@ -585,10 +585,15 @@ 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 + 2); rb_str_resize(s, (len = RSTRING_LEN(s)) + decpt - digs + 2);
if (decpt > digs) memset(RSTRING_PTR(s) + len, '0', decpt - digs); ptr = RSTRING_PTR(s) + len;
rb_str_cat(s, ".0", 2); if (decpt > digs) {
memset(ptr, '0', decpt - digs);
ptr += decpt - digs;
}
memcpy(ptr, ".0", 2);
} }
else { else {
goto exp; goto exp;