diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-02-22 11:06:38 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-02-22 11:06:38 +0900 |
| commit | ac936fc21103f8cc3c144f66c62b41cc8ee1165a (patch) | |
| tree | 85bd7fd1731bd25234983a65d3b215c8bde00a64 | |
| parent | 6b6c590fe356b4180673df30423a672e4a8e5316 (diff) | |
| download | mruby-ac936fc21103f8cc3c144f66c62b41cc8ee1165a.tar.gz mruby-ac936fc21103f8cc3c144f66c62b41cc8ee1165a.zip | |
powered num may be infinite in float-string conversion
| -rw-r--r-- | src/numeric.c | 8 |
1 files changed, 8 insertions, 0 deletions
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 */ |
