summaryrefslogtreecommitdiff
path: root/ext/-test-
diff options
context:
space:
mode:
Diffstat (limited to 'ext/-test-')
-rw-r--r--ext/-test-/bignum/big2str.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/ext/-test-/bignum/big2str.c b/ext/-test-/bignum/big2str.c
index 2c5df6a..794b4e8 100644
--- a/ext/-test-/bignum/big2str.c
+++ b/ext/-test-/bignum/big2str.c
@@ -32,9 +32,23 @@ big2str_poweroftwo(VALUE x, VALUE vbase)
return rb_big2str_poweroftwo(big(x), NUM2INT(vbase));
}
+#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
+static VALUE
+big2str_gmp(VALUE x, VALUE vbase)
+{
+ int base = NUM2INT(vbase);
+ if (base < 2 || 36 < base)
+ rb_raise(rb_eArgError, "invalid radix %d", base);
+ return rb_big2str_gmp(big(x), NUM2INT(vbase));
+}
+#else
+#define mul_gmp rb_f_notimplement
+#endif
+
void
Init_big2str(VALUE klass)
{
rb_define_method(rb_cInteger, "big2str_generic", big2str_generic, 1);
rb_define_method(rb_cInteger, "big2str_poweroftwo", big2str_poweroftwo, 1);
+ rb_define_method(rb_cInteger, "big2str_gmp", big2str_gmp, 1);
}