- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
void MainWindow::mathFun()
{
if(stringBuffer->indexOf("pi") != -1)
{
int i = stringBuffer->indexOf("pi");
stringArg2->clear();
stringArg2->append( stringBuffer->mid(i+2, stringBuffer->size()));
stringSum->clear();
stringSum->append(QString::number(stringArg2->toDouble() * 3.1415926));
ui->lineEdit->clear();
ui->lineEdit->insert(*stringSum);
qDebug() <<" i=" << i << " size=" << stringBuffer->size();
}
if(stringBuffer->indexOf("log") != -1)
{
int i = stringBuffer->indexOf("log");
stringArg2->clear();
stringArg2->append( stringBuffer->mid(i+3, stringBuffer->size()));
stringSum->clear();
stringSum->append(QString::number(qLn(stringArg2->toDouble())));
ui->lineEdit->clear();
ui->lineEdit->insert(*stringSum);
qDebug() <<" i=" << i << " size=" << stringBuffer->size();
}
if(stringBuffer->indexOf("sqr") != -1)
{
int i = stringBuffer->indexOf("sqr");
stringArg2->clear();
stringArg2->append( stringBuffer->mid(i+3, stringBuffer->size()));
stringSum->clear();
stringSum->append(QString::number(qSqrt(stringArg2->toDouble())));
ui->lineEdit->clear();
ui->lineEdit->insert(*stringSum);
qDebug() <<" i=" << i << " size=" << stringBuffer->size();
}
if(stringBuffer->indexOf("fac") != -1)
{
int i = stringBuffer->indexOf("fac");
stringArg2->clear();
stringArg2->append( stringBuffer->mid(i+3, stringBuffer->size()));
stringSum->clear();
long long j = 1;
for(int k = 1; k <= stringArg2->toInt(); ++k)
{
if(stringArg2->toInt() == 0)
{
ui->lineEdit->insert(QString::number(0));
return;
}
j *= 1 * k;
}
stringSum->append(QString::number(j));
ui->lineEdit->clear();
ui->lineEdit->insert(*stringSum);
qDebug() <<" i=" << i << " size=" << stringBuffer->size();
}
if(stringBuffer->indexOf("pow") != -1)
{
int i = stringBuffer->indexOf("pow");
stringArg1->clear();
stringArg1->append( stringBuffer->mid(0, i));
stringArg2->clear();
stringArg2->append( stringBuffer->mid(i+3, stringBuffer->size()));
stringSum->clear();
stringSum->append(QString::number( pow(stringArg1->toDouble(), stringArg2->toDouble())));
ui->lineEdit->clear();
ui->lineEdit->insert(*stringSum);
qDebug() <<" i=" << i << " size=" << stringBuffer->size();
}
if(stringBuffer->indexOf("exp") != -1)
{
int i = stringBuffer->indexOf("exp");
stringArg2->clear();
stringArg2->append( stringBuffer->mid(i+3, stringBuffer->size()));
stringSum->clear();
stringSum->append(QString::number(exp(stringArg2->toDouble())));
ui->lineEdit->clear();
ui->lineEdit->insert(*stringSum);
qDebug() <<" i=" << i << " size=" << stringBuffer->size();
}
if(stringBuffer->indexOf("mod") != -1)
{
int i = stringBuffer->indexOf("mod");
stringArg1->clear();
stringArg1->append( stringBuffer->mid(0, i));
stringArg2->clear();
stringArg2->append( stringBuffer->mid(i+3, stringBuffer->size()));
stringSum->clear();
stringSum->append(QString::number(fmod(stringArg1->toDouble(), stringArg2->toDouble())));
ui->lineEdit->clear();
ui->lineEdit->insert(*stringSum);
qDebug() <<" i=" << i << " size=" << stringBuffer->size();
}
stringSum->clear();
stringBuffer->clear();
}