mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
small fixes per chris's comments
This commit is contained in:
parent
d307b0914c
commit
11b4e7f7d8
12
Types.cpp
12
Types.cpp
@ -26,6 +26,8 @@
|
||||
#include <libsolidity/Types.h>
|
||||
#include <libsolidity/AST.h>
|
||||
|
||||
#include <limits>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace dev
|
||||
@ -322,13 +324,11 @@ TypePointer IntegerConstantType::binaryOperatorResult(Token::Value _operator, Ty
|
||||
break;
|
||||
case Token::Exp:
|
||||
if (other.m_value < 0)
|
||||
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("exponent can't be negative"));
|
||||
return TypePointer();
|
||||
else if (other.m_value > std::numeric_limits<unsigned int>::max())
|
||||
return TypePointer();
|
||||
else
|
||||
{
|
||||
value = boost::multiprecision::powm(m_value, other.m_value, bigint(2) << 256);
|
||||
if (value >= (bigint(1) << 256))
|
||||
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("exp result overflowed"));
|
||||
}
|
||||
value = boost::multiprecision::pow(m_value, other.m_value.convert_to<unsigned int>());
|
||||
break;
|
||||
default:
|
||||
return TypePointer();
|
||||
|
Loading…
Reference in New Issue
Block a user