summaryrefslogtreecommitdiff
path: root/ext/-test-/bignum/div.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/-test-/bignum/div.c')
-rw-r--r--ext/-test-/bignum/div.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/ext/-test-/bignum/div.c b/ext/-test-/bignum/div.c
new file mode 100644
index 00000000000..1706df99b55
--- /dev/null
+++ b/ext/-test-/bignum/div.c
@@ -0,0 +1,25 @@
+#include "ruby.h"
+#include "internal.h"
+
+static VALUE
+big(VALUE x)
+{
+ if (FIXNUM_P(x))
+ return rb_int2big(FIX2LONG(x));
+ if (RB_TYPE_P(x, T_BIGNUM))
+ return x;
+ rb_raise(rb_eTypeError, "can't convert %s to Bignum",
+ rb_obj_classname(x));
+}
+
+static VALUE
+divrem_normal(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_big_divrem_normal(big(x), big(y)));
+}
+
+void
+Init_div(VALUE klass)
+{
+ rb_define_method(rb_cInteger, "big_divrem_normal", divrem_normal, 1);
+}