summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
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;
}