diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-02-17 09:27:53 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-02-17 09:27:53 +0900 |
| commit | b4bc39568060d365829d2ace0f84f0ba382bfeb1 (patch) | |
| tree | a49bd909ce3b59df7a7ee5bc2e250b1d0e71ed55 /src/numeric.c | |
| parent | 09080fd2eeb38379d5059ce677451472b9904290 (diff) | |
| download | mruby-b4bc39568060d365829d2ace0f84f0ba382bfeb1.tar.gz mruby-b4bc39568060d365829d2ace0f84f0ba382bfeb1.zip | |
fdigit may be negative due to error if mrb_float is 32bit (e.g. 10**36 on 32bit arch); ref #1713 #1714
Diffstat (limited to 'src/numeric.c')
| -rw-r--r-- | src/numeric.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/numeric.c b/src/numeric.c index 9fc604547..41c559cee 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -159,6 +159,8 @@ mrb_flo_to_str(mrb_state *mrb, mrb_value flo, int max_digit) while (max_digit >= 0) { mrb_float weight = pow(10.0, m); mrb_float fdigit = n / weight; + + if (fdigit < 0) fdigit = n = 0; if (m < -1 && fdigit < FLT_EPSILON) { if (e || exp > 0 || m <= -abs(exp)) { break; |
