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:
Yukihiro "Matz" Matsumoto
2022-04-25 07:29:55 +09:00
parent f45ac65532
commit 0f4769536b
3 changed files with 3 additions and 4 deletions
+1 -1
View File
@@ -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
+1 -2
View File
@@ -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
View File
@@ -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