aboutsummaryrefslogtreecommitdiff
path: root/src/bignum.h
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2012-07-22 23:15:38 +0000
committerLuke Dashjr <luke-jr+git@utopios.org>2012-07-22 23:15:38 +0000
commitff4be740b56a733beb5c7978b56c6602fae51a2e (patch)
tree2ad1b7b202c6c44c17f499b8cf8c4aa174e62d60 /src/bignum.h
parent222ac2b12ab42d7a0ea66cd6fe4e25efa3c31333 (diff)
parent4f620dd0f0d0cd9ae1e2bb0403e07bd303e5b3ba (diff)
downloadbitcoin-ff4be740b56a733beb5c7978b56c6602fae51a2e.tar.xz
Merge branch '0.5.x' into 0.6.0.x
Diffstat (limited to 'src/bignum.h')
-rw-r--r--src/bignum.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/bignum.h b/src/bignum.h
index 9f75d7c789..69da72460f 100644
--- a/src/bignum.h
+++ b/src/bignum.h
@@ -131,7 +131,9 @@ public:
if (sn < (int64)0)
{
- n = -sn;
+ // Since the minimum signed integer cannot be represented as positive so long as its type is signed, and it's not well-defined what happens if you make it unsigned before negating it, we instead increment the negative integer by 1, convert it, then increment the (now positive) unsigned integer by 1 to compensate
+ n = -(sn + 1);
+ ++n;
fNegative = true;
} else {
n = sn;
@@ -414,7 +416,7 @@ public:
CBigNum& operator>>=(unsigned int shift)
{
// Note: BN_rshift segfaults on 64-bit if 2^shift is greater than the number
- // if built on ubuntu 9.04 or 9.10, probably depends on version of openssl
+ // if built on ubuntu 9.04 or 9.10, probably depends on version of OpenSSL
CBigNum a = 1;
a <<= shift;
if (BN_cmp(&a, this) > 0)