diff options
Diffstat (limited to 'src/com/android/calculator2/Evaluator.java')
-rw-r--r-- | src/com/android/calculator2/Evaluator.java | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/com/android/calculator2/Evaluator.java b/src/com/android/calculator2/Evaluator.java index 4ddaf15..9b9e830 100644 --- a/src/com/android/calculator2/Evaluator.java +++ b/src/com/android/calculator2/Evaluator.java @@ -776,10 +776,15 @@ class Evaluator { // syntax issues, and the expression is unchanged. // Return true otherwise. boolean append(int id) { - mChangedValue = (KeyMaps.digVal(id) != KeyMaps.NOT_DIGIT - || KeyMaps.isSuffix(id) - || id == R.id.const_pi || id == R.id.const_e); - return mExpr.add(id); + if (id == R.id.fun_10pow) { + add10pow(); // Handled as macro expansion. + return true; + } else { + mChangedValue = (KeyMaps.digVal(id) != KeyMaps.NOT_DIGIT + || KeyMaps.isSuffix(id) + || id == R.id.const_pi || id == R.id.const_e); + return mExpr.add(id); + } } void delete() { @@ -865,6 +870,17 @@ class Evaluator { mExpr.append(mSaved); } + // Add the power of 10 operator to the expression. This is treated + // essentially as a macro expansion. + private void add10pow() { + CalculatorExpr ten = new CalculatorExpr(); + ten.add(R.id.digit_1); + ten.add(R.id.digit_0); + mChangedValue = true; // For consistency. Reevaluation is probably not useful. + mExpr.append(ten); + mExpr.add(R.id.op_pow); + } + // Retrieve the main expression being edited. // It is the callee's reponsibility to call cancelAll to cancel // ongoing concurrent computations before modifying the result. |