lg instead log
This commit is contained in:
parent
d4bdbd3692
commit
fcea2f9e2e
@ -10,7 +10,7 @@
|
|||||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/eightDigitButton" a:text="8"
|
a:id="@+id/eightDigitButton" a:text="8"
|
||||||
calc:textUp="ln"
|
calc:textUp="ln"
|
||||||
calc:textDown="log"
|
calc:textDown="lg"
|
||||||
calc:directionTextScale="0.5"
|
calc:directionTextScale="0.5"
|
||||||
|
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
|
@ -33,7 +33,7 @@ public class Functions {
|
|||||||
public final static String ATANH = "atanh";
|
public final static String ATANH = "atanh";
|
||||||
|
|
||||||
public final static String LN = "ln";
|
public final static String LN = "ln";
|
||||||
public final static String LOG = "log";
|
public final static String LG = "lg";
|
||||||
|
|
||||||
public final static String MOD = "mod";
|
public final static String MOD = "mod";
|
||||||
public final static String EXP = "exp";
|
public final static String EXP = "exp";
|
||||||
@ -43,7 +43,7 @@ public class Functions {
|
|||||||
public static final List<String> allPrefix;
|
public static final List<String> allPrefix;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
final List<String> functions = new ArrayList<String>(Arrays.asList(SIN, SINH, ASIN, ASINH, COS, COSH, ACOS, ACOSH, TAN, TANH, ATAN, ATANH, LN, LOG, MOD, SQRT, EXP));
|
final List<String> functions = new ArrayList<String>(Arrays.asList(SIN, SINH, ASIN, ASINH, COS, COSH, ACOS, ACOSH, TAN, TANH, ATAN, ATANH, LN, LG, MOD, SQRT, EXP));
|
||||||
Collections.sort(functions, new MathEntityComparator());
|
Collections.sort(functions, new MathEntityComparator());
|
||||||
allPrefix = functions;
|
allPrefix = functions;
|
||||||
}
|
}
|
||||||
|
@ -179,6 +179,8 @@ public enum CalculatorEngine {
|
|||||||
//Log.d(CalculatorEngine.class.getName(), "Calculation thread started work: " + thread.getName());
|
//Log.d(CalculatorEngine.class.getName(), "Calculation thread started work: " + thread.getName());
|
||||||
calculationThread.setObject(thread);
|
calculationThread.setObject(thread);
|
||||||
calculationResult.setObject(finalOperation.evaluate(Expression.valueOf(jsclExpression)));
|
calculationResult.setObject(finalOperation.evaluate(Expression.valueOf(jsclExpression)));
|
||||||
|
} catch (ArithmeticException e) {
|
||||||
|
exception.setObject(new ParseException(e));
|
||||||
} catch (jscl.text.ParseException e) {
|
} catch (jscl.text.ParseException e) {
|
||||||
exception.setObject(new ParseException(e));
|
exception.setObject(new ParseException(e));
|
||||||
} catch (ParseInterruptedException e) {
|
} catch (ParseInterruptedException e) {
|
||||||
|
@ -63,6 +63,7 @@ public class CalculatorEngineTest {
|
|||||||
public void testEvaluate() throws Exception {
|
public void testEvaluate() throws Exception {
|
||||||
final CalculatorEngine cm = CalculatorEngine.instance;
|
final CalculatorEngine cm = CalculatorEngine.instance;
|
||||||
|
|
||||||
|
Assert.assertEquals("1", cm.evaluate(JsclOperation.numeric, "lg(10)").getResult());
|
||||||
Assert.assertEquals("4", cm.evaluate(JsclOperation.numeric, "2+2").getResult());
|
Assert.assertEquals("4", cm.evaluate(JsclOperation.numeric, "2+2").getResult());
|
||||||
Assert.assertEquals("-0.757", cm.evaluate(JsclOperation.numeric, "sin(4)").getResult());
|
Assert.assertEquals("-0.757", cm.evaluate(JsclOperation.numeric, "sin(4)").getResult());
|
||||||
Assert.assertEquals("0.524", cm.evaluate(JsclOperation.numeric, "asin(0.5)").getResult());
|
Assert.assertEquals("0.524", cm.evaluate(JsclOperation.numeric, "asin(0.5)").getResult());
|
||||||
|
Loading…
Reference in New Issue
Block a user