diff options
author | chriseth <chris@ethereum.org> | 2018-07-12 05:45:41 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-12 05:45:41 +0800 |
commit | 0c9645c9785740f9b8d906b1fe5f59b38ccc5782 (patch) | |
tree | 9b80135e08a372b8190f6507d5ba326c5e6ae092 /libsolidity | |
parent | 08345209e6f68c509ec5af820596a2172b886568 (diff) | |
parent | 08d0c9b7d72c63aff6ef38616f1c3e28e53353d1 (diff) | |
download | dexon-solidity-0c9645c9785740f9b8d906b1fe5f59b38ccc5782.tar.gz dexon-solidity-0c9645c9785740f9b8d906b1fe5f59b38ccc5782.tar.zst dexon-solidity-0c9645c9785740f9b8d906b1fe5f59b38ccc5782.zip |
Merge pull request #4480 from ethereum/fixZeroWithExponent
Fix literals with exponents with mantissa of zero.
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/ast/Types.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 0a4f199d..dd0736e9 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -771,20 +771,23 @@ tuple<bool, rational> RationalNumberType::isValidLiteral(Literal const& _literal } else if (expPoint != _literal.value().end()) { - // Parse base and exponent. Checks numeric limit. - bigint exp = bigint(string(expPoint + 1, _literal.value().end())); + // Parse mantissa and exponent. Checks numeric limit. + tuple<bool, rational> mantissa = parseRational(string(_literal.value().begin(), expPoint)); - if (exp > numeric_limits<int32_t>::max() || exp < numeric_limits<int32_t>::min()) + if (!get<0>(mantissa)) return make_tuple(false, rational(0)); + value = get<1>(mantissa); - uint32_t expAbs = bigint(abs(exp)).convert_to<uint32_t>(); - + // 0E... is always zero. + if (value == 0) + return make_tuple(true, rational(0)); - tuple<bool, rational> base = parseRational(string(_literal.value().begin(), expPoint)); + bigint exp = bigint(string(expPoint + 1, _literal.value().end())); - if (!get<0>(base)) + if (exp > numeric_limits<int32_t>::max() || exp < numeric_limits<int32_t>::min()) return make_tuple(false, rational(0)); - value = get<1>(base); + + uint32_t expAbs = bigint(abs(exp)).convert_to<uint32_t>(); if (exp < 0) { |