aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiacomo Tazzari <giacomo.tazzari@gmail.com>2014-08-11 17:06:32 +0800
committerGiacomo Tazzari <giacomo.tazzari@gmail.com>2014-08-11 17:06:32 +0800
commit17cb91aa35e3048723ac449b48d26038e6956de7 (patch)
tree9297c8ee0f694878f1d2a6bc0cc1c4b777a8c6ff
parentb3e207090337126cd48c5c827b6e0fd5c20c6097 (diff)
downloaddexon-solidity-17cb91aa35e3048723ac449b48d26038e6956de7.tar.gz
dexon-solidity-17cb91aa35e3048723ac449b48d26038e6956de7.tar.zst
dexon-solidity-17cb91aa35e3048723ac449b48d26038e6956de7.zip
Fixed implementation of EXP opcode (wrong results when exponent >= 2^32)
-rw-r--r--Assembly.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Assembly.cpp b/Assembly.cpp
index 78552f3c..550f5c89 100644
--- a/Assembly.cpp
+++ b/Assembly.cpp
@@ -230,7 +230,7 @@ Assembly& Assembly::optimise(bool _enable)
{ Instruction::SDIV, [](u256 a, u256 b)->u256{return s2u(u2s(a) / u2s(b));} },
{ Instruction::MOD, [](u256 a, u256 b)->u256{return a % b;} },
{ Instruction::SMOD, [](u256 a, u256 b)->u256{return s2u(u2s(a) % u2s(b));} },
- { Instruction::EXP, [](u256 a, u256 b)->u256{return boost::multiprecision::pow(a, (unsigned)b);} },
+ { Instruction::EXP, [](u256 a, u256 b)->u256{return (u256)boost::multiprecision::powm((bigint)a, (bigint)b, bigint(2) << 256);} },
{ Instruction::LT, [](u256 a, u256 b)->u256{return a < b ? 1 : 0;} },
{ Instruction::GT, [](u256 a, u256 b)->u256{return a > b ? 1 : 0;} },
{ Instruction::SLT, [](u256 a, u256 b)->u256{return u2s(a) < u2s(b) ? 1 : 0;} },