aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ast
diff options
context:
space:
mode:
authorRJ Catalano <rcatalano@macsales.com>2016-03-19 02:52:00 +0800
committerVoR0220 <catalanor0220@gmail.com>2016-05-10 00:41:02 +0800
commita1a2eac5fde0cd6f5aed206958434d655f9a194f (patch)
treebf3353587eefa7ec22f6e964c43b11babcc4e552 /libsolidity/ast
parent91fda50922865c1dbeed34652c30ac89f5edfadf (diff)
downloaddexon-solidity-a1a2eac5fde0cd6f5aed206958434d655f9a194f.tar.gz
dexon-solidity-a1a2eac5fde0cd6f5aed206958434d655f9a194f.tar.zst
dexon-solidity-a1a2eac5fde0cd6f5aed206958434d655f9a194f.zip
size capabilities functioning properly for fixed types
Diffstat (limited to 'libsolidity/ast')
-rw-r--r--libsolidity/ast/Types.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index a0915df9..d5e989ac 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -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;
}