diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-05-12 07:43:14 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-05-12 07:43:14 +0000 |
commit | d80a859d98a86e201075156a2b2cc5fa91aa4e08 (patch) | |
tree | 72239be9d685929ad72596a76b51faea86ddd8be /numeric.c | |
parent | d2a68945e6c20cf5e68ef27387b31ac102fd493f (diff) |
* 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
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -585,10 +585,15 @@ 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 + 2); - if (decpt > digs) memset(RSTRING_PTR(s) + len, '0', decpt - digs); - rb_str_cat(s, ".0", 2); + ptr = RSTRING_PTR(s) + len; + if (decpt > digs) { + memset(ptr, '0', decpt - digs); + ptr += decpt - digs; + } + memcpy(ptr, ".0", 2); } else { goto exp; |