diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2015-07-01 08:43:49 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2015-07-01 08:43:49 +0900 |
| commit | 18c82d535965d8656be2cf7e3394d89a51766bc2 (patch) | |
| tree | 3caa8f673db51c3fe82c2f775068d96ef66d8ed4 | |
| parent | 1c2fc94c207ab4d4a43d701e7a784fddd3328cad (diff) | |
| parent | d6865a9cc76c67b39bb29def7a62f9b9f752363c (diff) | |
| download | mruby-18c82d535965d8656be2cf7e3394d89a51766bc2.tar.gz mruby-18c82d535965d8656be2cf7e3394d89a51766bc2.zip | |
Merge pull request #2868 from sgnr/avoid-narrowing-cast-in-flo-round
Avoid a narrowing cast in flo_round under MRB_INT64.
| -rw-r--r-- | src/numeric.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/numeric.c b/src/numeric.c index 013273232..b9aef51d9 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -436,7 +436,7 @@ flo_round(mrb_state *mrb, mrb_value num) { double number, f; mrb_int ndigits = 0; - int i; + mrb_int i; mrb_get_args(mrb, "|i", &ndigits); number = mrb_float(num); @@ -451,7 +451,7 @@ flo_round(mrb_state *mrb, mrb_value num) } f = 1.0; - i = abs(ndigits); + i = ndigits >= 0 ? ndigits : -ndigits; while (--i >= 0) f = f*10.0; |
