mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #5095 from ethereum/type-assertions
Use better assertion messages for RationalNumberType::literalValue
This commit is contained in:
commit
7d4acae212
@ -1276,13 +1276,13 @@ u256 RationalNumberType::literalValue(Literal const*) const
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto fixed = fixedPointType();
|
auto fixed = fixedPointType();
|
||||||
solAssert(fixed, "");
|
solAssert(fixed, "Rational number cannot be represented as fixed point type.");
|
||||||
int fractionalDigits = fixed->fractionalDigits();
|
int fractionalDigits = fixed->fractionalDigits();
|
||||||
shiftedValue = m_value.numerator() * boost::multiprecision::pow(bigint(10), fractionalDigits) / m_value.denominator();
|
shiftedValue = m_value.numerator() * boost::multiprecision::pow(bigint(10), fractionalDigits) / m_value.denominator();
|
||||||
}
|
}
|
||||||
|
|
||||||
// we ignore the literal and hope that the type was correctly determined
|
// we ignore the literal and hope that the type was correctly determined
|
||||||
solAssert(shiftedValue <= u256(-1), "Integer constant too large.");
|
solAssert(shiftedValue <= u256(-1), "Number constant too large.");
|
||||||
solAssert(shiftedValue >= -(bigint(1) << 255), "Number constant too small.");
|
solAssert(shiftedValue >= -(bigint(1) << 255), "Number constant too small.");
|
||||||
|
|
||||||
if (m_value >= rational(0))
|
if (m_value >= rational(0))
|
||||||
|
Loading…
Reference in New Issue
Block a user