extended_exponent_fpt operator-(const extended_exponent_fpt& that) const {
   if (this->val_ == 0.0 ||
       that.exp_ > this->exp_ + _traits::kMaxSignificantExpDif) {
     return extended_exponent_fpt(-that.val_, that.exp_);
   }
   if (that.val_ == 0.0 ||
       this->exp_ > that.exp_ + _traits::kMaxSignificantExpDif) {
     return *this;
   }
   if (this->exp_ >= that.exp_) {
     exp_type exp_dif = this->exp_ - that.exp_;
     fpt_type val = std::ldexp(this->val_, exp_dif) - that.val_;
     return extended_exponent_fpt(val, that.exp_);
   } else {
     exp_type exp_dif = that.exp_ - this->exp_;
     fpt_type val = std::ldexp(-that.val_, exp_dif) + this->val_;
     return extended_exponent_fpt(val, this->exp_);
   }
 }
Exemple #2
0
 extended_exponent_fpt operator-(const extended_exponent_fpt& that) const {
   if (this->val_ == 0.0 ||
       that.exp_ > this->exp_ + _traits::MAX_SIGNIFICANT_EXP_DIF) {
     return extended_exponent_fpt(-that.val_, that.exp_);
   }
   if (that.val_ == 0.0 ||
       this->exp_ > that.exp_ + _traits::MAX_SIGNIFICANT_EXP_DIF) {
     return *this;
   }
   if (this->exp_ >= that.exp_) {
     exp_type exp_dif = this->exp_ - that.exp_;
     fpt_type val = std::ldexp(this->val_, exp_dif) - that.val_;
     return extended_exponent_fpt(val, that.exp_);
   } else {
     exp_type exp_dif = that.exp_ - this->exp_;
     fpt_type val = std::ldexp(-that.val_, exp_dif) + this->val_;
     return extended_exponent_fpt(val, this->exp_);
   }
 }
 extended_exponent_fpt operator/(const extended_exponent_fpt& that) const {
   fpt_type val = this->val_ / that.val_;
   exp_type exp = this->exp_ - that.exp_;
   return extended_exponent_fpt(val, exp);
 }
 extended_exponent_fpt operator-() const {
   return extended_exponent_fpt(-val_, exp_);
 }