Loading src/com/android/calculator2/CalculatorResult.java +35 −35 Original line number Diff line number Diff line Loading @@ -370,8 +370,12 @@ public class CalculatorResult extends AlignedTextView { boolean negative, int lastDisplayedOffset[], boolean forcePrecision) { final int minusSpace = negative ? 1 : 0; final int msdIndex = truncated ? -1 : getNaiveMsdIndexOf(in); // INVALID_MSD is OK. final int decIndex = in.indexOf('.'); String result = in; if (truncated || (negative && result.charAt(0) != '-')) { result = KeyMaps.ELLIPSIS + result.substring(1, result.length()); // Ellipsis may be removed again in the type(1) scientific notation case. } final int decIndex = result.indexOf('.'); lastDisplayedOffset[0] = precOffset; if ((decIndex == -1 || msdIndex != Evaluator.INVALID_MSD && msdIndex - decIndex > MAX_LEADING_ZEROES + 1) && precOffset != -1) { Loading Loading @@ -400,7 +404,7 @@ public class CalculatorResult extends AlignedTextView { exponent = initExponent + resLen - msdIndex - 1; hasPoint = true; } if (exponent != 0 || truncated) { // Exponent can't be zero. // Actually add the exponent of either type: if (!forcePrecision) { int dropDigits; // Digits to drop to make room for exponent. Loading Loading @@ -432,10 +436,6 @@ public class CalculatorResult extends AlignedTextView { lastDisplayedOffset[0] -= dropDigits; } result = result + "E" + Integer.toString(exponent); } // else don't add zero exponent } if (truncated || negative && result.charAt(0) != '-') { result = KeyMaps.ELLIPSIS + result.substring(1, result.length()); } return result; } Loading tests/README.txt +2 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,8 @@ Some interesting manual test cases: -10^30 - 10^10 -1.2x10^-9 -1.2x10^-8 -1.2x10^-10 -10^-12 1 - 10^-98 1 - 10^-100 1 - 10^-300 Loading Loading
src/com/android/calculator2/CalculatorResult.java +35 −35 Original line number Diff line number Diff line Loading @@ -370,8 +370,12 @@ public class CalculatorResult extends AlignedTextView { boolean negative, int lastDisplayedOffset[], boolean forcePrecision) { final int minusSpace = negative ? 1 : 0; final int msdIndex = truncated ? -1 : getNaiveMsdIndexOf(in); // INVALID_MSD is OK. final int decIndex = in.indexOf('.'); String result = in; if (truncated || (negative && result.charAt(0) != '-')) { result = KeyMaps.ELLIPSIS + result.substring(1, result.length()); // Ellipsis may be removed again in the type(1) scientific notation case. } final int decIndex = result.indexOf('.'); lastDisplayedOffset[0] = precOffset; if ((decIndex == -1 || msdIndex != Evaluator.INVALID_MSD && msdIndex - decIndex > MAX_LEADING_ZEROES + 1) && precOffset != -1) { Loading Loading @@ -400,7 +404,7 @@ public class CalculatorResult extends AlignedTextView { exponent = initExponent + resLen - msdIndex - 1; hasPoint = true; } if (exponent != 0 || truncated) { // Exponent can't be zero. // Actually add the exponent of either type: if (!forcePrecision) { int dropDigits; // Digits to drop to make room for exponent. Loading Loading @@ -432,10 +436,6 @@ public class CalculatorResult extends AlignedTextView { lastDisplayedOffset[0] -= dropDigits; } result = result + "E" + Integer.toString(exponent); } // else don't add zero exponent } if (truncated || negative && result.charAt(0) != '-') { result = KeyMaps.ELLIPSIS + result.substring(1, result.length()); } return result; } Loading
tests/README.txt +2 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,8 @@ Some interesting manual test cases: -10^30 - 10^10 -1.2x10^-9 -1.2x10^-8 -1.2x10^-10 -10^-12 1 - 10^-98 1 - 10^-100 1 - 10^-300 Loading