summaryrefslogtreecommitdiff
path: root/rational.c
diff options
context:
space:
mode:
Diffstat (limited to 'rational.c')
-rw-r--r--rational.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/rational.c b/rational.c
index 517a797..e504979 100644
--- a/rational.c
+++ b/rational.c
@@ -404,6 +404,9 @@ f_lcm(VALUE x, VALUE y)
adat = ((struct RRational *)(x));\
bdat = ((struct RRational *)(y))
+#define RRATIONAL_SET_NUM(rat, n) RB_OBJ_WRITE((rat), &((struct RRational *)(rat))->num,(n))
+#define RRATIONAL_SET_DEN(rat, d) RB_OBJ_WRITE((rat), &((struct RRational *)(rat))->den,(d))
+
inline static VALUE
nurat_s_new_internal(VALUE klass, VALUE num, VALUE den)
{
@@ -1775,6 +1778,18 @@ rb_Rational(VALUE x, VALUE y)
return nurat_s_convert(2, a, rb_cRational);
}
+VALUE
+rb_rational_num(VALUE rat)
+{
+ return nurat_numerator(rat);
+}
+
+VALUE
+rb_rational_den(VALUE rat)
+{
+ return nurat_denominator(rat);
+}
+
#define id_numerator rb_intern("numerator")
#define f_numerator(x) rb_funcall((x), id_numerator, 0)