Merge pull request #6680 from ethereum/fixExp

Fix interpreter exp bug.
This commit is contained in:
chriseth 2019-05-07 12:39:35 +02:00 committed by GitHub
commit 2370eefa74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -0,0 +1,9 @@
{
mstore(0, exp(3,not(1)))
}
// ----
// Trace:
// MSTORE_AT_SIZE(0, 32) [8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e39]
// Memory dump:
// 0: 8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e39
// Storage dump:

View File

@ -42,7 +42,7 @@ u256 exp256(u256 _base, u256 _exponent)
u256 result = 1;
while (_exponent)
{
if (static_cast<limb_type>(_exponent) & 1) // If exponent is odd.
if (boost::multiprecision::bit_test(_exponent, 0))
result *= _base;
_base *= _base;
_exponent >>= 1;