From 962f59a3755ee50e0bfbbf7013a546ae68da6143 Mon Sep 17 00:00:00 2001 From: matz Date: Sat, 9 Sep 2006 15:27:34 +0000 Subject: * bignum.c (rb_big_mul0): bignum multiplication without normalization. * bignum.c (rb_big_pow): use rb_big_mul0(). [ruby-dev:29547] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ bignum.c | 29 ++++++++++++++++++----------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 925b009566..7c0ada679f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sat Sep 9 23:50:38 2006 Yukihiro Matsumoto + + * bignum.c (rb_big_mul0): bignum multiplication without + normalization. + + * bignum.c (rb_big_pow): use rb_big_mul0(). [ruby-dev:29547] + Sat Sep 9 14:08:38 2006 Eric Hodel * lib/test/unit/testcase.rb (Test::Unit::TestCase#run): Rescue diff --git a/bignum.c b/bignum.c index df702e26ca..b5d405b7f2 100644 --- a/bignum.c +++ b/bignum.c @@ -1206,15 +1206,8 @@ rb_big_minus(x, y) } } -/* - * call-seq: - * big * other => Numeric - * - * Multiplies big and other, returning the result. - */ - VALUE -rb_big_mul(x, y) +rb_big_mul0(x, y) VALUE x, y; { long i, j; @@ -1257,7 +1250,21 @@ rb_big_mul(x, y) } } - return bignorm(z); + return z; +} + +/* + * call-seq: + * big * other => Numeric + * + * Multiplies big and other, returning the result. + */ + +VALUE +rb_big_mul(x, y) + VALUE x, y; +{ + return bignorm(rb_big_mul0(x, y)); } static void @@ -1616,10 +1623,10 @@ rb_big_pow(x, y) if (yy == 0) break; while (yy % 2 == 0) { yy /= 2; - x = rb_big_mul(x, x); + x = rb_big_mul0(x, x); if (!BDIGITS(x)[RBIGNUM(x)->len-1]) RBIGNUM(x)->len--; } - z = rb_big_mul(z, x); + z = rb_big_mul0(z, x); if (!BDIGITS(z)[RBIGNUM(z)->len-1]) RBIGNUM(z)->len--; } return bignorm(z); -- cgit v1.2.3