aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-02-15 00:36:22 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-03-15 21:06:26 +0800
commit1083e6da683b9624b1bb6cc2b3cc3831504dfc57 (patch)
treebe4e07c029e2aed40130a9bdfb903c217dd6dc66
parent6014c3fe16e2d4c42c1bd710661885a5f787a715 (diff)
downloaddexon-solidity-1083e6da683b9624b1bb6cc2b3cc3831504dfc57.tar.gz
dexon-solidity-1083e6da683b9624b1bb6cc2b3cc3831504dfc57.tar.zst
dexon-solidity-1083e6da683b9624b1bb6cc2b3cc3831504dfc57.zip
Support negative exponent
-rw-r--r--libsolidity/ast/Types.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index aecf830d..39760353 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -584,8 +584,7 @@ tuple<bool, rational> RationalNumberType::isValidLiteral(Literal const& _literal
if (expPoint != _literal.value().end())
{
if (
- !all_of(_literal.value().begin(), expPoint, ::isdigit) ||
- !all_of(expPoint + 1, _literal.value().end(), ::isdigit)
+ !all_of(_literal.value().begin(), expPoint, ::isdigit)
)
return make_tuple(false, rational(0));
@@ -595,10 +594,16 @@ tuple<bool, rational> RationalNumberType::isValidLiteral(Literal const& _literal
return make_tuple(false, rational(0));
x = bigint(string(_literal.value().begin(), expPoint));
- x *= boost::multiprecision::pow(
- bigint(10),
- exp.convert_to<int32_t>()
- );
+ if (exp < 0)
+ x /= boost::multiprecision::pow(
+ bigint(10),
+ abs(exp).convert_to<int32_t>()
+ );
+ else
+ x *= boost::multiprecision::pow(
+ bigint(10),
+ exp.convert_to<int32_t>()
+ );
}
else if (radixPoint != _literal.value().end())
{