diff --git a/test/libyul/yulInterpreterTests/exp.yul b/test/libyul/yulInterpreterTests/exp.yul new file mode 100644 index 000000000..1cdba5839 --- /dev/null +++ b/test/libyul/yulInterpreterTests/exp.yul @@ -0,0 +1,9 @@ +{ + mstore(0, exp(3,not(1))) +} +// ---- +// Trace: +// MSTORE_AT_SIZE(0, 32) [8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e39] +// Memory dump: +// 0: 8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e39 +// Storage dump: diff --git a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp index 4fea1b50c..1a03704b4 100644 --- a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp +++ b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp @@ -42,7 +42,7 @@ u256 exp256(u256 _base, u256 _exponent) u256 result = 1; while (_exponent) { - if (static_cast(_exponent) & 1) // If exponent is odd. + if (boost::multiprecision::bit_test(_exponent, 0)) result *= _base; _base *= _base; _exponent >>= 1;