diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-09-06 10:21:42 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-09-06 10:21:42 +0900 |
| commit | fc1f7c4bf0a7ec762e730f7ee183cb0d3e0bf9da (patch) | |
| tree | 7526b5a51703aeef99e6c9b9e6b5c02bb7fb14c3 /src | |
| parent | ab3db07752cc8ad852740bc676e9f45d5e8a0ed4 (diff) | |
| download | mruby-fc1f7c4bf0a7ec762e730f7ee183cb0d3e0bf9da.tar.gz mruby-fc1f7c4bf0a7ec762e730f7ee183cb0d3e0bf9da.zip | |
numeric.c: shortcut overflowing operation when `ndigit` is too small.
Diffstat (limited to 'src')
| -rw-r--r-- | src/numeric.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/numeric.c b/src/numeric.c index 1a006b7e3..fd9f5ce2c 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -907,6 +907,7 @@ flo_round(mrb_state *mrb, mrb_value num) mrb_check_num_exact(mrb, number); f = 1.0; + if (ndigits < -DBL_DIG-2) return mrb_fixnum_value(0); i = ndigits >= 0 ? ndigits : -ndigits; if (ndigits > DBL_DIG+2) return num; while (--i >= 0) |
