From eacdcc13d81eb4ff418fb99acc8e438d1dd838a3 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Mon, 17 Feb 2014 10:11:51 +0900 Subject: remove trailing zeros from float string representation --- src/numeric.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') 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'; -- cgit v1.2.3