mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
src/numeric.c: use mrb_ensure_float_type().
Instead of obsolete `mrb_to_float()` or the combination of `mrb_float_value(mrb_as_float())`.
This commit is contained in:
@@ -191,7 +191,7 @@ mrb_f_float(mrb_state *mrb, mrb_value self)
|
||||
if (mrb_string_p(arg)) {
|
||||
return mrb_float_value(mrb, mrb_str_to_dbl(mrb, arg, TRUE));
|
||||
}
|
||||
return mrb_to_float(mrb, arg);
|
||||
return mrb_ensure_float_type(mrb, arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1395,8 +1395,7 @@ mrb_pack_pack(mrb_state *mrb, mrb_value ary)
|
||||
#ifndef MRB_NO_FLOAT
|
||||
else if (type == PACK_TYPE_FLOAT) {
|
||||
if (!mrb_float_p(o)) {
|
||||
mrb_float f = mrb_as_float(mrb, o);
|
||||
o = mrb_float_value(mrb, f);
|
||||
o = mrb_ensure_float_type(mrb, o);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -259,7 +259,7 @@ coerce_step_counter(mrb_state *mrb, mrb_value self)
|
||||
#ifndef MRB_NO_FLOAT
|
||||
mrb->c->ci->mid = 0;
|
||||
if (mrb_float_p(num) || mrb_float_p(step)) {
|
||||
return mrb_to_float(mrb, self);
|
||||
return mrb_ensure_float_type(mrb, self);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user