summaryrefslogtreecommitdiff
path: root/complex.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-16 08:15:05 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-16 08:15:05 +0900
commitca524bcd494e2f284c3211cad8e8dde70e8aa86a (patch)
tree0b64cd0673bacdb2209c7b5e8e97244e7f3f38f9 /complex.c
parent34019a22eb41206e3d5d1ac29b3874275aa7f71c (diff)
Expanded f_numerator
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/complex.c b/complex.c
index 74d91b044f..fa00036ffb 100644
--- a/complex.c
+++ b/complex.c
@@ -192,6 +192,18 @@ f_arg(VALUE x)
}
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)
{
if (RB_TYPE_P(x, T_RATIONAL)) {
@@ -221,7 +233,6 @@ f_negate(VALUE x)
return rb_funcall(x, id_negate, 0);
}
-fun1(numerator)
fun1(real_p)
inline static VALUE