Rename `mrb_flo_to_fixnum` to `mrb_float_to_integer`.

parent fbbcee83
......@@ -154,12 +154,15 @@ mrb_int_mul_overflow(mrb_int a, mrb_int b, mrb_int *c)
# define MRB_FLT_MAX_10_EXP DBL_MAX_10_EXP
# endif /* MRB_USE_FLOAT32 */
MRB_API mrb_value mrb_flo_to_fixnum(mrb_state *mrb, mrb_value val);
MRB_API mrb_value mrb_float_to_integer(mrb_state *mrb, mrb_value val);
MRB_API mrb_value mrb_float_to_str(mrb_state *mrb, mrb_value x, const char *fmt);
/* ArgumentError if format string doesn't match /%(\.[0-9]+)?[aAeEfFgG]/ */
MRB_API int mrb_float_to_cstr(mrb_state *mrb, char *buf, size_t len, const char *fmt, mrb_float f);
MRB_API mrb_float mrb_to_flo(mrb_state *mrb, mrb_value x);
/* obsolete function(s); will be removed */
#define mrb_flo_to_fixnum(mrb, val) mrb_float_to_integer(mrb, val)
#endif /* MRB_NO_FLOAT */
MRB_END_DECL
......
......@@ -898,9 +898,8 @@ retry:
switch (mrb_type(val)) {
#ifndef MRB_NO_FLOAT
case MRB_TT_FLOAT:
val = mrb_flo_to_fixnum(mrb, val);
if (mrb_integer_p(val)) goto bin_retry;
break;
val = mrb_float_to_integer(mrb, val);
goto bin_retry;
#endif
case MRB_TT_STRING:
val = mrb_str_to_inum(mrb, val, 0, TRUE);
......
......@@ -1357,13 +1357,12 @@ int_to_f(mrb_state *mrb, mrb_value num)
*/
/* ------------------------------------------------------------------------*/
MRB_API mrb_value
mrb_flo_to_fixnum(mrb_state *mrb, mrb_value x)
mrb_float_to_integer(mrb_state *mrb, mrb_value x)
{
mrb_int z = 0;
if (!mrb_float_p(x)) {
mrb_raise(mrb, E_TYPE_ERROR, "non float value");
z = 0; /* not reached. just suppress warnings. */
}
else {
mrb_float d = mrb_float(x);
......
......@@ -513,7 +513,7 @@ mrb_to_int(mrb_state *mrb, mrb_value val)
if (!mrb_integer_p(val)) {
#ifndef MRB_NO_FLOAT
if (mrb_float_p(val)) {
return mrb_flo_to_fixnum(mrb, val);
return mrb_float_to_integer(mrb, val);
}
#endif
if (mrb_string_p(val)) {
......@@ -537,7 +537,7 @@ mrb_convert_to_integer(mrb_state *mrb, mrb_value val, mrb_int base)
#ifndef MRB_NO_FLOAT
case MRB_TT_FLOAT:
if (base != 0) goto arg_error;
return mrb_flo_to_fixnum(mrb, val);
return mrb_float_to_integer(mrb, val);
#endif
case MRB_TT_INTEGER:
......
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