aboutsummaryrefslogtreecommitdiffstats
path: root/bignum.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-24 14:31:49 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-24 14:31:49 +0000
commit13f1fbc09a0984ad7779d5819785597f20241d19 (patch)
tree821c43b3eaa7fe2723071673665fe096c9fc62bf /bignum.c
parent66ee8a17852bb7657712afd3ac088a8b9b293d71 (diff)
downloadruby-13f1fbc09a0984ad7779d5819785597f20241d19.tar.gz
* bignum.c (integer_unpack_single_bdigit): Refine code to filling
higher bits and use BIGLO. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/bignum.c b/bignum.c
index 0bdceef045..ffd35cf5e4 100644
--- a/bignum.c
+++ b/bignum.c
@@ -1350,8 +1350,10 @@ integer_unpack_single_bdigit(BDIGIT u, size_t size, int flags, BDIGIT *dp)
sign = (flags & INTEGER_PACK_NEGATIVE) ?
((size == SIZEOF_BDIGITS && u == 0) ? -2 : -1) :
((u >> (size * CHAR_BIT - 1)) ? -1 : 1);
- if (sign < 0)
- u = (BDIGIT)(-(u | LSHIFTX((~(BDIGIT)0), size * CHAR_BIT)));
+ if (sign < 0) {
+ u |= LSHIFTX(BDIGMAX, size * CHAR_BIT);
+ u = BIGLO(-u);
+ }
}
else
sign = (flags & INTEGER_PACK_NEGATIVE) ? -1 : 1;