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)))); } }
SchemeUnit* Rational::isEql(Number* number2) { if (!number2->exact_) { return new Boolean(false); } else if (number2->type_ == 1) { Rational* tmp2 = SCAST_RATIONAL(number2); Rational* tmp_dif = SCAST_RATIONAL(sub(tmp2)); if (tmp_dif->num_ == ZERO_) return new Boolean(true); else return new Boolean(false); } else if (number2->type_ == 3) { Complex* tmp2 = SCAST_COMPLEX(number2); Rational* tmp2_real = SCAST_RATIONAL(tmp2->real_); Rational* tmp2_imag = SCAST_RATIONAL(tmp2->imag_); if (tmp2_imag->num_!=ZERO_) return new Boolean(false); else { Rational* tmp_dif = SCAST_RATIONAL(sub(tmp2_real)); if (tmp_dif->num_ == ZERO_) return new Boolean(true); else return new Boolean(false); } } }
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_)); } }