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

Commit fcb1e611 authored by Hans Boehm's avatar Hans Boehm Committed by Android (Google) Code Review
Browse files

Merge "Fix COPY string computation in exact case" into ub-calculator-euler

parents 3aa4d05b 3465c782
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ public class CalculatorResult extends AlignedTextView implements MenuItem.OnMenu
                            // append an exponent insteadd of replacing trailing digits.
    private final Object mWidthLock = new Object();
                            // Protects the next five fields.  These fields are only
                            // Updated by the UI thread, and read accesses by the UI thread
                            // updated by the UI thread, and read accesses by the UI thread
                            // sometimes do not acquire the lock.
    private int mWidthConstraint = 0;
                            // Our total width in pixels minus space for ellipsis.
@@ -837,7 +837,7 @@ public class CalculatorResult extends AlignedTextView implements MenuItem.OnMenu
     * UI thread only.
     */
    public boolean fullTextIsExact() {
        return !mScrollable || (mMaxCharOffset == getCharOffset(mCurrentPos)
        return !mScrollable || (getCharOffset(mMaxPos) == getCharOffset(mCurrentPos)
                && mMaxCharOffset != MAX_RIGHT_SCROLL);
    }

@@ -855,9 +855,14 @@ public class CalculatorResult extends AlignedTextView implements MenuItem.OnMenu
            return getFullText(false /* withSeparators */);
        }
        // It's reasonable to compute and copy the exact result instead.
        final int nonNegLsdOffset = Math.max(0, mLsdOffset);
        final String rawResult = mEvaluator.getResult(mIndex).toStringTruncated(nonNegLsdOffset);
        final String formattedResult = formatResult(rawResult, nonNegLsdOffset, MAX_COPY_SIZE,
        int fractionLsdOffset = Math.max(0, mLsdOffset);
        String rawResult = mEvaluator.getResult(mIndex).toStringTruncated(fractionLsdOffset);
        if (mLsdOffset <= -1) {
            // Result has trailing decimal point. Remove it.
            rawResult = rawResult.substring(0, rawResult.length() - 1);
            fractionLsdOffset = -1;
        }
        final String formattedResult = formatResult(rawResult, fractionLsdOffset, MAX_COPY_SIZE,
                false, rawResult.charAt(0) == '-', null, true /* forcePrecision */,
                false /* forceSciNotation */, false /* insertCommas */);
        return KeyMaps.translateResult(formattedResult);
+1 −0
Original line number Diff line number Diff line
@@ -366,6 +366,7 @@ public class UnifiedReal {
     * Returns a truncated representation of the result.
     * If exactlyTruncatable(), we round correctly towards zero. Otherwise the resulting digit
     * string may occasionally be rounded up instead.
     * Always includes a decimal point in the result.
     * The result includes n digits to the right of the decimal point.
     * @param n result precision, >= 0
     */