Support negative exponent

This commit is contained in:
Alex Beregszaszi 2017-02-14 16:36:22 +00:00
parent 6014c3fe16
commit 1083e6da68

View File

@ -584,8 +584,7 @@ tuple<bool, rational> RationalNumberType::isValidLiteral(Literal const& _literal
if (expPoint != _literal.value().end()) if (expPoint != _literal.value().end())
{ {
if ( if (
!all_of(_literal.value().begin(), expPoint, ::isdigit) || !all_of(_literal.value().begin(), expPoint, ::isdigit)
!all_of(expPoint + 1, _literal.value().end(), ::isdigit)
) )
return make_tuple(false, rational(0)); return make_tuple(false, rational(0));
@ -595,6 +594,12 @@ tuple<bool, rational> RationalNumberType::isValidLiteral(Literal const& _literal
return make_tuple(false, rational(0)); return make_tuple(false, rational(0));
x = bigint(string(_literal.value().begin(), expPoint)); x = bigint(string(_literal.value().begin(), expPoint));
if (exp < 0)
x /= boost::multiprecision::pow(
bigint(10),
abs(exp).convert_to<int32_t>()
);
else
x *= boost::multiprecision::pow( x *= boost::multiprecision::pow(
bigint(10), bigint(10),
exp.convert_to<int32_t>() exp.convert_to<int32_t>()