summaryrefslogtreecommitdiffhomepage
path: root/src/numeric.c
diff options
context:
space:
mode:
authorSimon Génier <[email protected]>2015-06-29 13:37:16 -0400
committerSimon Génier <[email protected]>2015-06-29 20:19:19 -0400
commitd6865a9cc76c67b39bb29def7a62f9b9f752363c (patch)
tree3caa8f673db51c3fe82c2f775068d96ef66d8ed4 /src/numeric.c
parent1c2fc94c207ab4d4a43d701e7a784fddd3328cad (diff)
downloadmruby-d6865a9cc76c67b39bb29def7a62f9b9f752363c.tar.gz
mruby-d6865a9cc76c67b39bb29def7a62f9b9f752363c.zip
Avoid a narrowing cast in flo_round under MRB_INT64.
Diffstat (limited to 'src/numeric.c')
-rw-r--r--src/numeric.c4
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;