object.c: add conversion to Float from Rational, Complex; #5620

parent 7f40b645
......@@ -512,6 +512,10 @@ mrb_ensure_float_type(mrb_state *mrb, mrb_value val)
case MRB_TT_FLOAT:
return val;
case MRB_TT_RATIONAL:
case MRB_TT_COMPLEX:
return mrb_type_convert(mrb, val, MRB_TT_FLOAT, MRB_SYM(to_f));
default:
mrb_raisef(mrb, E_TYPE_ERROR, "%Y cannot be converted to Float", val);
/* not reached */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment