本文整理汇总了C++中Float::convert方法的典型用法代码示例。如果您正苦于以下问题:C++ Float::convert方法的具体用法?C++ Float::convert怎么用?C++ Float::convert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Float
的用法示例。
在下文中一共展示了Float::convert方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Float
Number *Complex::expt(Number *number2){
Complex *tmp = SCAST_COMPLEX(number2);
Float *f = new Float();
Float *real1 =SCAST_FLOAT(f->convert(real_));
Float *imag1 = SCAST_FLOAT(f->convert(imag_));
Float *real2 = SCAST_FLOAT(f->convert(tmp->real_));
Float *imag2 = SCAST_FLOAT(f->convert(tmp->imag_));
complex<double> a(real1->number_, imag1->number_), b(real2->number_, imag2->number_);
complex<double> res = pow(a, b);
Float *real = new Float(res.real()), *imag = new Float(res.imag());
if (real->number_ == -0) real->number_ = 0;
Complex *result = new Complex(real, imag);
delete f, real1, imag1, real2, imag2, real, imag;
return result;
}
示例2: acoss
Number* Rational::acoss()
{
Float* res = new Float;
Float* tmp = SCAST_FLOAT(res->convert(this));
if (fabs(tmp->number_)<=1.0)
{
res->number_=asin(tmp->number_);
delete tmp;
return res;
}
else if (tmp->number_>0)
{
complex<double> c_a(tmp->number_,0.0);
complex<double> c_res = asin(c_a);
Complex* res = new Complex;
res->exact_ = false;
res->real_ = new Float(::real(c_res));
res->imag_ = new Float(::imag(c_res));
delete tmp;
return res;
}
else
{
complex<double> c_a(fabs(tmp->number_),0.0);
complex<double> c_res = asin(c_a);
Complex* res = new Complex;
res->exact_ = false;
res->real_ = new Float(::real(c_res)+PI);
res->imag_ = new Float(0.0-::imag(c_res));
delete tmp;
return res;
}
}
示例3: atann
Number* Rational::atann()
{
Float* res = new Float;
Float* tmp2 = SCAST_FLOAT(res->convert(this));
res->number_ = atan(tmp2->number_);
delete tmp2;
return res;
}
示例4: expp
Number* Rational::expp(Number* number2)
{
Rational* rtmp2 = SCAST_RATIONAL(number2);
if (num_==ZERO_ && rtmp2->num_==ZERO_) return new Float(1);
else if (num_==ZERO_ && rtmp2->num_!=ZERO_) return new Float(0);
if(num_.sgn_)
{
Complex* c = new Complex;
c = SCAST_COMPLEX(c->convert(this));
Complex* d = SCAST_COMPLEX(c->convert(rtmp2));
return c->expp(d);
}
else
{
Float* tmpf = new Float;
tmpf = SCAST_FLOAT(tmpf->convert(rtmp2));
return new Float(pow(SCAST_FLOAT(tmpf->convert(this))->number_, tmpf->number_));
}
}
示例5: expt
Number* Rational::expt(Number* obj){
if(sgn()<0){
Complex* c = new Complex();
c = SCAST_COMPLEX(c->convert(this));
Complex* d = SCAST_COMPLEX(c->convert(obj));
return c->expt(d);
}else{
Float* tmpf = new Float();
tmpf = SCAST_FLOAT(tmpf->convert(obj));
return new Float(pow(double(*this), double(*SCAST_RATIONAL(obj))));
}
}
示例6: sqt
Number* Rational::sqt()
{
if (!num_.sgn_) return new Float(sqrt((double)num_/(double)den_));
else
{
Complex* resc = new Complex;
Float* real = new Float(0.0);
Float* imag = new Float(sqrt(fabs(SCAST_FLOAT(real->convert(this))->number_)));
resc->real_ = real; resc->imag_ = imag; resc->exact_=false;
return resc;
}
}
示例7: logg
Number* Rational::logg()
{
assert(num_!=ZERO_ && "undefined log0");
if (!num_.sgn_)
{
Float* tmpf = new Float;
tmpf = SCAST_FLOAT(tmpf->convert(this));
return new Float(log(tmpf->number_));
}
else
{
Float* tmp = new Float;
tmp = SCAST_FLOAT(tmp->convert(this));
complex<double> c_x(tmp->number_,0.0);
complex<double> c_res = log(c_x);
Complex* res = new Complex;
res->exact_ = false;
res->real_ = new Float(::real(c_res));
res->imag_ = new Float(::imag(c_res));
delete tmp;
return res;
}
}
示例8: exttoinext
Number* Rational::exttoinext()
{
Float* res = new Float;
return res->convert(this);
}
示例9: expe
Number* Rational::expe()
{
Float* tmpf = new Float;
tmpf = SCAST_FLOAT(tmpf->convert(this));
return new Float(exp(tmpf->number_));
}