double factorial
This commit is contained in:
parent
69a25604a3
commit
7bb5c02d6c
@ -10,7 +10,7 @@
|
||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:id="@+id/eightDigitButton" a:text="8"
|
||||
calc:textUp="ln"
|
||||
calc:textLeft="0b:"
|
||||
calc:textLeft="0o:"
|
||||
calc:textDown="lg"
|
||||
calc:directionTextScale="0.5;0.5;0.5;0.33"
|
||||
style="?digitButtonStyle"
|
||||
|
@ -10,7 +10,7 @@
|
||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:id="@+id/nineDigitButton" a:text="9"
|
||||
calc:textDown="e"
|
||||
calc:textLeft="0o:"
|
||||
calc:textLeft="0x:"
|
||||
calc:textUp="π"
|
||||
calc:directionTextScale="0.5;0.5;0.5;0.33"
|
||||
style="?digitButtonStyle"
|
||||
|
@ -10,7 +10,7 @@
|
||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:id="@+id/sevenDigitButton" a:text="7"
|
||||
calc:textUp="i"
|
||||
calc:textLeft="0x:"
|
||||
calc:textLeft="0b:"
|
||||
calc:textDown="!"
|
||||
calc:directionTextScale="0.5;0.5;0.5;0.33"
|
||||
style="?digitButtonStyle"
|
||||
|
@ -183,6 +183,7 @@
|
||||
<string name="c_op_description_integral_ab">Интегрирует функцию \'f(x)\' по переменной \'x\' от \'a\' до \'b\'.</string>
|
||||
|
||||
<string name="c_pf_description_factorial">Возвращает факториал от предыдущего выражения.</string>
|
||||
<string name="c_pf_description_double_factorial">Возвращает двойной факториал от предыдущего выражения.</string>
|
||||
<string name="c_pf_description_percent" formatted="false">Возвращает процентное значение от предыдущего выражения.\nПримеры:\n
|
||||
100 + 50% = 150\n
|
||||
100 * 50% = 50\n
|
||||
|
@ -184,6 +184,7 @@
|
||||
<string name="c_op_description_integral_ab">Integrates function \'f(x)\' by \'x\' variable from \'a\' to \'b\'.</string>
|
||||
|
||||
<string name="c_pf_description_factorial">Gives the factorial of the expression before.</string>
|
||||
<string name="c_pf_description_double_factorial">Gives the double factorial of the expression before.</string>
|
||||
<string name="c_pf_description_percent" formatted="false">Gives the percent value of the expression
|
||||
before.\nExamples:\n
|
||||
100 + 50% = 150\n
|
||||
|
@ -146,6 +146,7 @@ public class TextHighlighter implements TextProcessor<TextHighlighter.Result, St
|
||||
if (mathType.getMathType() == MathType.text || match.length() <= 1) {
|
||||
text1.append(text.charAt(i));
|
||||
} else {
|
||||
text1.append(match);
|
||||
i += match.length() - 1;
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ public class AndroidPostfixFunctionsRegistry extends AndroidMathRegistryImpl<Ope
|
||||
static {
|
||||
substitutes.put("%", "percent");
|
||||
substitutes.put("!", "factorial");
|
||||
substitutes.put("!!", "double_factorial");
|
||||
substitutes.put("°", "degree");
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,7 @@ public class TextHighlighterTest {
|
||||
Assert.assertEquals("22x", textHighlighter.process("22x").toString());
|
||||
Assert.assertEquals("20t", textHighlighter.process("20t").toString());
|
||||
Assert.assertEquals("20k", textHighlighter.process("20k").toString());
|
||||
Assert.assertEquals("3!!", textHighlighter.process("3!!").toString());
|
||||
Assert.assertEquals("2", textHighlighter.process("2").toString());
|
||||
Assert.assertEquals("21", textHighlighter.process("21").toString());
|
||||
Assert.assertEquals("214", textHighlighter.process("214").toString());
|
||||
|
@ -113,7 +113,7 @@ public class CalculatorEngineTest {
|
||||
Assert.assertEquals("2+i", cm.evaluate(JsclOperation.numeric, "2*1+√(-1)").getResult());
|
||||
try {
|
||||
cm.getEngine().setAngleUnits(AngleUnit.rad);
|
||||
Assert.assertEquals("0.921+3.142i", cm.evaluate(JsclOperation.numeric, "ln(5cosh(38π√(2cos(2))))").getResult());
|
||||
Assert.assertEquals("0.921+πi", cm.evaluate(JsclOperation.numeric, "ln(5cosh(38π√(2cos(2))))").getResult());
|
||||
Assert.assertEquals("-3.41+3.41i", cm.evaluate(JsclOperation.numeric, "(5tan(2i)+2i)/(1-i)").getResult());
|
||||
} finally {
|
||||
cm.getEngine().setAngleUnits(defaultAngleUnit);
|
||||
@ -132,7 +132,7 @@ public class CalculatorEngineTest {
|
||||
junit.framework.Assert.assertEquals("120", cm.evaluate(JsclOperation.numeric, "(2+2+1)!").getResult());
|
||||
junit.framework.Assert.assertEquals("24", cm.evaluate(JsclOperation.numeric, "(2.0+2.0)!").getResult());
|
||||
junit.framework.Assert.assertEquals("24", cm.evaluate(JsclOperation.numeric, "4.0!").getResult());
|
||||
junit.framework.Assert.assertEquals("720", cm.evaluate(JsclOperation.numeric, "3!!").getResult());
|
||||
junit.framework.Assert.assertEquals("720", cm.evaluate(JsclOperation.numeric, "(3!)!").getResult());
|
||||
junit.framework.Assert.assertEquals("36", Expression.valueOf("3!^2").numeric().toString());
|
||||
junit.framework.Assert.assertEquals("3", Expression.valueOf("cubic(27)").numeric().toString());
|
||||
try {
|
||||
@ -353,7 +353,7 @@ public class CalculatorEngineTest {
|
||||
Assert.assertEquals("11 259 375", cm.evaluate(JsclOperation.numeric, "0x:ABCDEF").getResult());
|
||||
Assert.assertEquals("30 606 154.462", cm.evaluate(JsclOperation.numeric, "0x:ABCDEF*e").getResult());
|
||||
Assert.assertEquals("30 606 154.462", cm.evaluate(JsclOperation.numeric, "e*0x:ABCDEF").getResult());
|
||||
Assert.assertEquals("2.718", cm.evaluate(JsclOperation.numeric, "e*0x:ABCDEF/0x:ABCDEF").getResult());
|
||||
Assert.assertEquals("e", cm.evaluate(JsclOperation.numeric, "e*0x:ABCDEF/0x:ABCDEF").getResult());
|
||||
Assert.assertEquals("30 606 154.462", cm.evaluate(JsclOperation.numeric, "0x:ABCDEF*e*0x:ABCDEF/0x:ABCDEF").getResult());
|
||||
Assert.assertEquals("30 606 154.462", cm.evaluate(JsclOperation.numeric, "c+0x:ABCDEF*e*0x:ABCDEF/0x:ABCDEF-c+0x:C-0x:C").getResult());
|
||||
Assert.assertEquals("1 446 257 064 651.832", cm.evaluate(JsclOperation.numeric, "28*28 * sin(28) - 0b:1101 + √(28) + exp ( 28) ").getResult());
|
||||
|
Loading…
Reference in New Issue
Block a user