summaryrefslogtreecommitdiffhomepage
path: root/src/numeric.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-02-17 10:11:51 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-02-17 10:11:51 +0900
commiteacdcc13d81eb4ff418fb99acc8e438d1dd838a3 (patch)
treea46f06d4b62aec0b253894cb45c85801c30dd423 /src/numeric.c
parenta740b28b529f2fb2cf66446e2ee816fdcee11371 (diff)
downloadmruby-eacdcc13d81eb4ff418fb99acc8e438d1dd838a3.tar.gz
mruby-eacdcc13d81eb4ff418fb99acc8e438d1dd838a3.zip
remove trailing zeros from float string representation
Diffstat (limited to 'src/numeric.c')
-rw-r--r--src/numeric.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/numeric.c b/src/numeric.c
index 5526e6034..18dd1e5bf 100644
--- a/src/numeric.c
+++ b/src/numeric.c
@@ -181,6 +181,12 @@ mrb_flo_to_str(mrb_state *mrb, mrb_value flo)
*(c++) = '.';
}
}
+ if (c[-1] == '0') {
+ while (&s[0] < c && c[-1] == '0') {
+ c--;
+ }
+ c++;
+ }
if (e) {
*(c++) = 'e';