Expanded f_numerator

This commit is contained in:
Nobuyoshi Nakada 2019-07-16 08:15:05 +09:00
parent 34019a22eb
commit ca524bcd49
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
3 changed files with 16 additions and 4 deletions

View file

@ -191,6 +191,18 @@ f_arg(VALUE x)
return rb_funcall(x, id_arg, 0);
}
inline static VALUE
f_numerator(VALUE x)
{
if (RB_TYPE_P(x, T_RATIONAL)) {
return RRATIONAL(x)->num;
}
if (RB_FLOAT_TYPE_P(x)) {
return rb_float_numerator(x);
}
return x;
}
inline static VALUE
f_denominator(VALUE x)
{
@ -221,7 +233,6 @@ f_negate(VALUE x)
return rb_funcall(x, id_negate, 0);
}
fun1(numerator)
fun1(real_p)
inline static VALUE