summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-01 14:34:53 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-01 14:34:53 +0000
commitb64c2c348f05784cb3dad92c97093baf3e93885f (patch)
treefbd057fa4f4d160c2d605bfa471c49497f2ff11f /ext
parent4dd7a13a0a00d66592049e1f9a79a9cfddf11a07 (diff)
* bignum.c (GMP_BIG2STR_DIGITS): New constant.
(big2str_gmp): New function. (rb_big2str1): Use big2str_gmp for big bignums. * internal.h (rb_big2str_gmp): Declared. * ext/-test-/bignum/big2str.c (big2str_gmp): New method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-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);
}