From ac936fc21103f8cc3c144f66c62b41cc8ee1165a Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sat, 22 Feb 2014 11:06:38 +0900 Subject: powered num may be infinite in float-string conversion --- src/numeric.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/numeric.c b/src/numeric.c index 0789a7654..c17b9c251 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -148,6 +148,14 @@ mrb_flo_to_str(mrb_state *mrb, mrb_value flo) /* exponent representation */ e = TRUE; n = n / pow(10.0, exp); + if (isinf(n)) { + if (s[0] == '-') { + return mrb_str_new_lit(mrb, "-0.0"); + } + else { + return mrb_str_new_lit(mrb, "0.0"); + } + } } else { /* un-exponent (normal) representation */ -- cgit v1.2.3