diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-02-17 10:11:51 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-02-17 10:11:51 +0900 |
| commit | eacdcc13d81eb4ff418fb99acc8e438d1dd838a3 (patch) | |
| tree | a46f06d4b62aec0b253894cb45c85801c30dd423 /src | |
| parent | a740b28b529f2fb2cf66446e2ee816fdcee11371 (diff) | |
| download | mruby-eacdcc13d81eb4ff418fb99acc8e438d1dd838a3.tar.gz mruby-eacdcc13d81eb4ff418fb99acc8e438d1dd838a3.zip | |
remove trailing zeros from float string representation
Diffstat (limited to 'src')
| -rw-r--r-- | src/numeric.c | 6 |
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'; |
