30 #include <kmessagebox.h>
53 return left_op | right_op;
57 return left_op ^ right_op;
61 return left_op & right_op;
65 return left_op << right_op;
69 return left_op >> right_op;
73 return left_op + right_op;
77 return left_op - right_op;
81 return left_op * right_op;
85 return left_op / right_op;
89 return left_op % right_op;
97 return left_op.
bin(right_op);
101 return left_op.
pow(right_op);
117 return left_op * right_op /
KNumber(100);
121 return left_op *
KNumber(100) / right_op;
141 typedef KNumber(*Prcnt)(
const KNumber &,
const KNumber &);
143 struct operator_data {
150 const struct operator_data Operator[] = {
159 { 5, ExecAdd, ExecAddP},
160 { 5, ExecSubtract, ExecSubP},
161 { 6, ExecMultiply, ExecMultiplyP},
162 { 6, ExecDivide, ExecDivideP},
164 { 6, ExecIntDiv, NULL},
165 { 7, ExecBinom, NULL},
166 { 7, ExecPower, NULL},
167 { 7, ExecPwrRoot, NULL}
205 last_number_ = Rad2Deg(input.
acos());
214 last_number_ = input.
acos();
237 last_number_ = Rad2Gra(input.
acos());
261 last_number_ = Rad2Deg(input.
asin());
271 last_number_ = input.
asin();
295 last_number_ = Rad2Gra(input.
asin());
307 last_number_ = Rad2Deg(input.
atan());
321 last_number_ = input.
atan();
333 last_number_ = Rad2Gra(input.
atan());
353 last_number_ = input.
acosh();
369 last_number_ = input.
asinh();
383 if (input == KNumber::One) {
387 if (input == - KNumber::One) {
391 last_number_ = input.
atanh();
401 last_number_ = ~input;
411 KNumber trunc_input = moveIntoDegInterval(input);
424 else kDebug() <<
"Something wrong in CalcEngine::CosDeg";
429 trunc_input = Deg2Rad(trunc_input);
430 last_number_ = trunc_input.
cos();
440 last_number_ = input.
cos();
449 KNumber trunc_input = moveIntoGradInterval(input);
461 else kDebug() <<
"Something wrong in CalcEngine::CosGrad";
465 trunc_input = Gra2Rad(trunc_input);
467 last_number_ = trunc_input.
cos();
483 last_number_ = input.
cosh();
488 last_number_ = input * input * input;
493 last_number_ = input.
cbrt();
540 last_number_ = input.
tgamma();
545 last_number_ = -input;
557 last_number_ = input.
ln();
570 last_number_ = input.
log10();
577 while (!stack_.isEmpty()) {
578 Node tmp_node = stack_.
pop();
581 input = evalOperation(tmp_node.number, tmp_node.operation, input);
583 last_number_ = input;
605 KNumber trunc_input = moveIntoDegInterval(input);
617 else kDebug() <<
"Something wrong in CalcEngine::SinDeg";
621 trunc_input = Deg2Rad(trunc_input);
623 last_number_ = trunc_input.
sin();
633 last_number_ = input.
sin();
643 KNumber trunc_input = moveIntoGradInterval(input);
655 else kDebug() <<
"Something wrong in CalcEngine::SinGrad";
660 trunc_input = Gra2Rad(trunc_input);
662 last_number_ = trunc_input.
sin();
674 last_number_ = input.
sinh();
679 last_number_ = input * input;
684 last_number_ = input.
sqrt();
715 last_number_ = stats.
mean();
717 error_ = stats.
error();
723 last_number_ = stats.
median();
725 error_ = stats.
error();
731 last_number_ = stats.
std();
733 error_ = stats.
error();
741 error_ = stats.
error();
747 last_number_ = stats.
sum();
755 error_ = stats.
error();
770 last_number_ = arg1 / arg2;
785 last_number_ = arg1 / arg2;
800 last_number_ = arg1 / arg2;
812 last_number_ = input.
tanh();
817 if (!percent_mode_ || Operator[operation].prcnt_ptr == NULL) {
818 return (Operator[operation].arith_ptr)(arg1, arg2);
820 percent_mode_ =
false;
821 return (Operator[operation].prcnt_ptr)(arg1, arg2);
833 stack_.
push(tmp_node);
839 percent_mode_ =
true;
842 tmp_node.number = number;
843 tmp_node.operation = func;
845 stack_.
push(tmp_node);
850 bool CalcEngine::evalStack()
853 Q_ASSERT(!stack_.isEmpty());
855 Node tmp_node = stack_.
pop();
857 while (! stack_.isEmpty()) {
858 Node tmp_node2 = stack_.
pop();
859 if (Operator[tmp_node.operation].precedence <=
860 Operator[tmp_node2.operation].precedence) {
862 const KNumber tmp_result = evalOperation(tmp_node2.number, tmp_node2.operation, tmp_node.number);
863 tmp_node.number = tmp_result;
865 stack_.
push(tmp_node2);
872 stack_.
push(tmp_node);
874 last_number_ = tmp_node.number;
void CosGrad(const KNumber &input)
void Square(const KNumber &input)
void Complement(const KNumber &input)
void SquareRoot(const KNumber &input)
KNumber pow(const KNumber &x) const
void AreaSinHyp(const KNumber &input)
static const KNumber NegInfinity
void CosDeg(const KNumber &input)
void enterOperation(const KNumber &num, Operation func)
void StatSumSquares(const KNumber &input)
void TangensDeg(const KNumber &input)
static const KNumber Zero
void Reciprocal(const KNumber &input)
void TangensHyp(const KNumber &input)
void CubeRoot(const KNumber &input)
void ParenOpen(const KNumber &input)
void Exp(const KNumber &input)
void SinRad(const KNumber &input)
void StatMedian(const KNumber &input)
KNumber integerPart() const
void TangensRad(const KNumber &input)
void StatMean(const KNumber &input)
KNumber bin(const KNumber &x) const
void Cube(const KNumber &input)
void SinHyp(const KNumber &input)
void StatStdSample(const KNumber &input)
void enterData(const KNumber &data)
void SinDeg(const KNumber &input)
void ArcCosGrad(const KNumber &input)
void ArcSinDeg(const KNumber &input)
void ArcTangensDeg(const KNumber &input)
void ArcCosDeg(const KNumber &input)
void SinGrad(const KNumber &input)
void CosHyp(const KNumber &input)
void AreaTangensHyp(const KNumber &input)
void CosRad(const KNumber &input)
void Log10(const KNumber &input)
void StatSum(const KNumber &input)
void Factorial(const KNumber &input)
void ArcSinGrad(const KNumber &input)
void ArcSinRad(const KNumber &input)
void StatClearAll(const KNumber &input)
void AreaCosHyp(const KNumber &input)
void TangensGrad(const KNumber &input)
KNumber lastOutput(bool &error) const
static const KNumber PosInfinity
KNumber factorial() const
void StatDataDel(const KNumber &input)
void ParenClose(KNumber input)
void Gamma(const KNumber &input)
void ArcCosRad(const KNumber &input)
void ArcTangensRad(const KNumber &input)
void InvertSign(const KNumber &input)
void StatStdDeviation(const KNumber &input)
void StatDataNew(const KNumber &input)
static const KNumber NegOne
KNumber sum_of_squares() const
void Exp10(const KNumber &input)
void StatCount(const KNumber &input)
void ArcTangensGrad(const KNumber &input)
void Ln(const KNumber &input)