本文整理汇总了C++中Constante::getXAsFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ Constante::getXAsFloat方法的具体用法?C++ Constante::getXAsFloat怎么用?C++ Constante::getXAsFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Constante
的用法示例。
在下文中一共展示了Constante::getXAsFloat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tanh
Element* Calculateur::tanh()
{
if(typeid(*this->pileC->top()) == typeid(Expression))
{
this->eval();
}
if(typeid(*this->pileC->top()) == typeid(Complexe))
{
//
}
if(isRadian())
{
Constante* tmp = dynamic_cast<Constante*> (this->pileC->pop());
Reel* resu = new Reel(::tanh(tmp->getXAsFloat()/tmp->getYAsFloat()));
delete tmp;
this->pileC->push(resu);
return resu;
}
else
{
Constante* tmp = dynamic_cast<Constante*> (this->pileC->pop());
Reel* resu = new Reel(::tanh((tmp->getXAsFloat()/tmp->getYAsFloat())*PI/180.0));
delete tmp;
this->pileC->push(resu);
return resu;
}
}
示例2: inv
Element* Calculateur::inv()
{
if(typeid(*this->pileC->top()) == typeid(Expression))
{
throw std::logic_error("L'élément du haut de la pile est une expression");
}
if(typeid(*this->pileC->top()) == typeid(Complexe))
{
throw std::logic_error("L'inverse d'un complexe n'est pas une commande disponible");
}
Constante* c = dynamic_cast<Constante *>(this->pileC->pop());
Element* res;
if(typeid(*c)== typeid(Entier) || typeid(*c)== typeid(Rationnel))
{
res = new Rationnel(c->getYAsInt(),c->getXAsInt());
}
else
{
res = new Reel(1./c->getXAsFloat());
}
delete c;
this->pileC->push(res);
return res;
}
示例3: log
Element* Calculateur::log()
{
if(typeid(*this->pileC->top()) == typeid(Expression))
{
this->eval();
}
if(typeid(*this->pileC->top()) == typeid(Complexe))
{
//
}
if(isRadian())
{
Constante* tmp = dynamic_cast<Constante*> (this->pileC->pop());
if(tmp->getXAsFloat()<0 && tmp->getYAsFloat() <0)
{
//ERREUR
return 0;
}
else
{
Reel* resu = new Reel(::log10(tmp->getXAsFloat()/tmp->getYAsFloat()));
delete tmp;
this->pileC->push(resu);
return resu;
}
}
else
{
Constante* tmp = dynamic_cast<Constante*> (this->pileC->pop());
if(tmp->getXAsFloat()<0 && tmp->getYAsFloat() <0)
{
//ERREUR
return 0;
}
else
{
Reel* resu = new Reel(::log10((tmp->getXAsFloat()/tmp->getYAsFloat())));
delete tmp;
this->pileC->push(resu);
return resu;
}
}
}
示例4: pow
Element* Calculateur::pow()
{
if(typeid(*this->pileC->top()) == typeid(Expression))
{
this->eval();
}
if(typeid(*this->pileC->top()) == typeid(Complexe))
{
throw std::logic_error("Le premier élément ne peut pas être un complexe");
}
else if(typeid(*this->pileC->top())== typeid(Entier))
{
Entier* e = dynamic_cast<Entier*>(this->pileC->pop());
if(typeid(*this->pileC->top()) == typeid(Expression))
{
Element* tmp = this->eval();
}
else if(typeid(*this->pileC->top())== typeid(Entier) || typeid(*this->pileC->top())== typeid(Rationnel))
{
Constante* c = dynamic_cast<Constante*>(this->pileC->pop());
if(e->getXAsInt()>= 0)
{
Rationnel* tmp = new Rationnel(::pow(c->getXAsInt(),e->getXAsInt()),::pow(c->getYAsInt(),e->getXAsInt()));
qDebug()<<tmp->toQString();
Element* res = this->cast(tmp);
delete e;
delete c;
delete tmp;
this->pileC->push(res);
}
else
{
Reel* tmp = new Reel(::pow(c->getXAsFloat()/c->getYAsFloat(),e->getXAsInt()));
Element* res = this->cast(tmp);
delete e;
delete c;
delete tmp;
this->pileC->push(res);
}
}
else if(typeid(*this->pileC->top()) == typeid(Reel))
{
Constante* c = dynamic_cast<Constante*>(this->pileC->pop());
Reel* tmp = new Reel(::pow(c->getXAsFloat(),e->getXAsFloat()));
Element* res = this->cast(tmp);
delete e;
delete c;
delete tmp;
this->pileC->push(res);
}
else
{
throw std::logic_error("L'élément n'est pas un type connu");
}
}
else if(typeid(*this->pileC->top()) == typeid(Reel) || typeid(*this->pileC->top()) == typeid(Rationnel))
{
Constante* p = dynamic_cast<Constante*>(this->pileC->pop());
if((typeid(*this->pileC->top()) == typeid(Entier))||(typeid(*this->pileC->top()) == typeid(Rationnel)) || typeid(*this->pileC->top()) == typeid(Reel))
{
Constante* c = dynamic_cast<Constante*>(this->pileC->pop());
Reel* tmp = new Reel(::pow(c->getXAsFloat()/c->getYAsFloat(),p->getXAsFloat()/p->getYAsFloat()));
Element* res = this->cast(tmp);
delete p;
delete c;
delete tmp;
this->pileC->push(res);
return res;
}
else
{
throw std::logic_error("Le deuxième élément n'est pas un type valide");
}
}
else
{
throw std::logic_error("Le premier élément n'est pas un élément valide");
}
}