summaryrefslogtreecommitdiff
path: root/ext/bigdecimal/bigdecimal.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-20 15:42:23 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-20 15:42:23 +0000
commita461f2f8bb5b79954421b6b3d3756f9011ad32e9 (patch)
treee3a0b2d63fa0ef198afba91fc127fa7ea8512e4d /ext/bigdecimal/bigdecimal.c
parenta0d42f035421dabf54500ef83a34df2bf09573ea (diff)
* ext/bigdecimal: Workaround fix for bigdecimal test failures caused
by [ruby-dev:47413] [Feature #8509] * ext/bigdecimal/bigdecimal.h (BDIGIT): Make it independent from the definition for bignum.c. (SIZEOF_BDIGITS): Ditto. (BDIGIT_DBL): Ditto. (BDIGIT_DBL_SIGNED): Ditto. (PRI_BDIGIT_PREFIX): Undefine the definition. (PRI_BDIGIT_DBL_PREFIX): Ditto. * ext/bigdecimal/bigdecimal.c (RBIGNUM_ZERO_P): Use rb_bigzero_p. (bigzero_p): Removed. (is_even): Use rb_big_pack. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal/bigdecimal.c')
-rw-r--r--ext/bigdecimal/bigdecimal.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 360a3e79d9..ba8777635f 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -86,23 +86,9 @@ static ID id_eq;
#endif
#ifndef RBIGNUM_ZERO_P
-# define RBIGNUM_ZERO_P(x) (RBIGNUM_LEN(x) == 0 || \
- (RBIGNUM_DIGITS(x)[0] == 0 && \
- (RBIGNUM_LEN(x) == 1 || bigzero_p(x))))
+# define RBIGNUM_ZERO_P(x) rb_bigzero_p(x)
#endif
-static inline int
-bigzero_p(VALUE x)
-{
- long i;
- BDIGIT *ds = RBIGNUM_DIGITS(x);
-
- for (i = RBIGNUM_LEN(x) - 1; 0 <= i; i--) {
- if (ds[i]) return 0;
- }
- return 1;
-}
-
#ifndef RRATIONAL_ZERO_P
# define RRATIONAL_ZERO_P(x) (FIXNUM_P(RRATIONAL(x)->num) && \
FIX2LONG(RRATIONAL(x)->num) == 0)
@@ -2130,7 +2116,11 @@ is_even(VALUE x)
return (FIX2LONG(x) % 2) == 0;
case T_BIGNUM:
- return (RBIGNUM_DIGITS(x)[0] % 2) == 0;
+ {
+ unsigned long l;
+ rb_big_pack(x, &l, 1);
+ return l % 2 == 0;
+ }
default:
break;