aboutsummaryrefslogtreecommitdiff
path: root/src/uint256.h
diff options
context:
space:
mode:
authorThomas Holenstein <thomas.holenstein@gmail.com>2013-12-21 16:50:49 +0100
committerThomas Holenstein <thomas.holenstein@gmail.com>2013-12-25 11:07:21 +0100
commite85e19be06c59529bfda100729e8ef3148349952 (patch)
treec1be2bb3178a5e9a9eadd61cded2067094f83271 /src/uint256.h
parent6e7792003b5c520fcc81d223f07471d690594081 (diff)
Changed Get64(.) to GetLow64()
The function Get64(.) has a bug in case the width is not divisible by 64. Since it is only ever used as Get64(0) this simply changes it to this special case. Additionally, an assert is added, and a cast to prevent a compiler error.
Diffstat (limited to 'src/uint256.h')
-rw-r--r--src/uint256.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/uint256.h b/src/uint256.h
index 7dbb3f83bb..c19d82ceb5 100644
--- a/src/uint256.h
+++ b/src/uint256.h
@@ -203,7 +203,7 @@ public:
{
// prefix operator
int i = 0;
- while (--pn[i] == -1 && i < WIDTH-1)
+ while (--pn[i] == (uint32_t)-1 && i < WIDTH-1)
i++;
return *this;
}
@@ -370,9 +370,10 @@ public:
return sizeof(pn);
}
- uint64_t Get64(int n=0) const
+ uint64_t GetLow64() const
{
- return pn[2*n] | (uint64_t)pn[2*n+1] << 32;
+ assert(WIDTH >= 2);
+ return pn[0] | (uint64_t)pn[1] << 32;
}
// unsigned int GetSerializeSize(int nType=0, int nVersion=PROTOCOL_VERSION) const