summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-22 10:50:21 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-22 10:50:21 +0000
commit350e8342f93e3679da790494b4d448bea8ebf819 (patch)
treec721ad95dd12759e81c2edbeabf1d0cb19da581b /bignum.c
parenta9a081793cc84543742f91eda1949ffb8b4e0d41 (diff)
* bignum.c (BIGZEROP): fix for longer Bignum zeros. [ruby-Bugs-17454]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/bignum.c b/bignum.c
index 3e85f04246..9a5bd0c228 100644
--- a/bignum.c
+++ b/bignum.c
@@ -37,7 +37,21 @@ VALUE rb_cBignum;
#define BIGLO(x) ((BDIGIT)((x) & (BIGRAD-1)))
#define BDIGMAX ((BDIGIT)-1)
-#define BIGZEROP(x) (RBIGNUM(x)->len == 0 || (RBIGNUM(x)->len == 1 && BDIGITS(x)[0] == 0))
+#define BIGZEROP(x) (RBIGNUM(x)->len == 0 || \
+ (BDIGITS(x)[0] == 0 && \
+ (RBIGNUM(x)->len == 1 || bigzero_p(x))))
+
+static int bigzero_p(VALUE);
+static int
+bigzero_p(x)
+ VALUE x;
+{
+ long i;
+ for (i = 0; i < RBIGNUM(x)->len; ++i) {
+ if (BDIGITS(x)[i]) return 0;
+ }
+ return 1;
+}
static VALUE
bignew_1(klass, len, sign)