summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2016-10-18 05:22:29 (GMT)
committerSteve Kondik <steve@cyngn.com>2016-10-18 05:22:29 (GMT)
commitde1be370a90c3549a5591657b8f3f253c465709a (patch)
tree4d2ae0bff1242d50470eec82733f2d0e8be20b1a
parent2d20bbc22422514f6d09abf8fd36772647c85c9e (diff)
parent82d19f315fc49a972bc29bd86dbdddb45f13d3b6 (diff)
downloadandroid_packages_apps_ExactCalculator-cm-14.0.zip
android_packages_apps_ExactCalculator-cm-14.0.tar.gz
android_packages_apps_ExactCalculator-cm-14.0.tar.bz2
Merge tag 'LA.UM.5.5.r1-00900-8x96.0' of git://codeaurora.org/platform/packages/apps/ExactCalculator into cm-14.0cm-14.0
"LA.UM.5.5.r1-00900-8x96.0"
-rwxr-xr-x[-rw-r--r--]src/com/android/calculator2/CalculatorExpr.java23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/com/android/calculator2/CalculatorExpr.java b/src/com/android/calculator2/CalculatorExpr.java
index 14d9236..40da4a1 100644..100755
--- a/src/com/android/calculator2/CalculatorExpr.java
+++ b/src/com/android/calculator2/CalculatorExpr.java
@@ -873,19 +873,25 @@ class CalculatorExpr {
* Unlike the "general" case using logarithms, this handles a negative base.
*/
private static CR pow(CR base, BigInteger exp) {
- if (exp.compareTo(BigInteger.ZERO) < 0) {
- return pow(base, exp.negate()).inverse();
+ BigInteger bigInteger = new BigInteger(exp.toString());
+
+ if (bigInteger.compareTo(BigInteger.ZERO) < 0) {
+ return pow(base, bigInteger.negate()).inverse();
}
- if (exp.equals(BigInteger.ONE)) {
+
+ if (bigInteger.equals(BigInteger.ONE)) {
return base;
}
- if (exp.and(BigInteger.ONE).intValue() == 1) {
- return pow(base, exp.subtract(BigInteger.ONE)).multiply(base);
+
+ if (bigInteger.and(BigInteger.ONE).intValue() == 1) {
+ return pow(base, bigInteger.subtract(BigInteger.ONE)).multiply(base);
}
- if (exp.equals(BigInteger.ZERO)) {
+
+ if (bigInteger.equals(BigInteger.ZERO)) {
return CR.valueOf(1);
}
- CR tmp = pow(base, exp.shiftRight(1));
+
+ CR tmp = pow(base, bigInteger.shiftRight(1));
return tmp.multiply(tmp);
}
@@ -961,7 +967,8 @@ class CalculatorExpr {
// values. That wouldn't work reliably with floating point either.
BigInteger int_exp = BoundedRational.asBigInteger(exp.ratVal);
if (int_exp != null) {
- crVal = pow(crVal, int_exp);
+ BigInteger bigInteger = new BigInteger(int_exp.toString());
+ crVal = pow(crVal, bigInteger);
} else {
crVal = crVal.ln().multiply(exp.val).exp();
}