Skip to content

Commit

Permalink
size capabilities functioning properly for fixed types
Browse files Browse the repository at this point in the history
  • Loading branch information
RJ Catalano authored and VoR0220 committed May 9, 2016
1 parent 91fda50 commit a1a2eac
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions libsolidity/ast/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,16 +580,11 @@ bool ConstantNumberType::isImplicitlyConvertibleTo(Type const& _convertTo) const
int forSignBit = (targetType->isSigned() ? 1 : 0);
if (m_value > 0)
{
if (
m_value <= (u256(-1) >> (256 - targetType->numBits() + forSignBit)) &&
m_scalingFactor <= targetType->fractionalBits()
)
bool properlyScaledBits = m_scalingFactor <= targetType->fractionalBits() ?
true : m_scalingFactor == 1 && targetType->fractionalBits() == 0 ? true : false;
if (m_value <= (u256(-1) >> (256 - targetType->numBits() + forSignBit)) && properlyScaledBits)
return true;
else if (
targetType->isSigned() &&
-m_value <= (u256(1) >> (256 - targetType->numBits() + forSignBit)) &&
m_scalingFactor <= targetType->fractionalBits()
)
else if (targetType->isSigned() && -m_value <= (u256(1) << (targetType->numBits() - forSignBit)) && properlyScaledBits)
return true;
return false;
}
Expand Down

0 comments on commit a1a2eac

Please sign in to comment.