Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47270616 authored by Hans Boehm's avatar Hans Boehm Committed by Android Git Automerger
Browse files

am e4b8ff7c: Don\'t evaluate a lone decimal point to zero

* commit 'e4b8ff7c':
  Don't evaluate a lone decimal point to zero
parents b7be7bfd e4b8ff7c
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -217,12 +217,19 @@ class CalculatorExpr {
        }

        /**
         * Return BoundedRational representation of constant.
         * Never null.
         * Return BoundedRational representation of constant, if well-formed.
         * Result is never null.
         */
        public BoundedRational toRational() {
        public BoundedRational toRational() throws SyntaxException {
            String whole = mWhole;
            if (whole.isEmpty()) whole = "0";
            if (whole.isEmpty()) {
                if (mFraction.isEmpty()) {
                    // Decimal point without digits.
                    throw new SyntaxException();
                } else {
                    whole = "0";
                }
            }
            BigInteger num = new BigInteger(whole + mFraction);
            BigInteger den = BigInteger.TEN.pow(mFraction.length());
            if (mExponent > 0) {