bool ieee_not_equal(const ieee_floatt &a, const ieee_floatt &b) { if(a.NaN || b.NaN) return true; // !!! if(a.is_zero() && b.is_zero()) return false; assert(a.spec==b.spec); return a!=b; }
bool ieee_floatt::operator<(const ieee_floatt &other) const { if(NaN_flag || other.NaN_flag) return false; // check both zero? if(is_zero() && other.is_zero()) return false; // one of them zero? if(is_zero()) return !other.sign_flag; else if(other.is_zero()) return sign_flag; // check sign if(sign_flag!=other.sign_flag) return sign_flag; // handle infinity if(infinity_flag) { if(other.infinity_flag) return false; else return sign_flag; } else if(other.infinity_flag) return !sign_flag; // check exponent if(exponent!=other.exponent) { if(sign_flag) // both negative return exponent>other.exponent; else return exponent<other.exponent; } // check significand if(sign_flag) // both negative return fraction>other.fraction; else return fraction<other.fraction; }
bool ieee_floatt::ieee_not_equal(const ieee_floatt &other) const { if(NaN_flag || other.NaN_flag) return true; // !!! if(is_zero() && other.is_zero()) return false; assert(spec==other.spec); return *this!=other; }
bool operator <=(const ieee_floatt &a, const ieee_floatt &b) { if(a.NaN || b.NaN) return false; // check zero if(a.is_zero() && b.is_zero()) return true; //handle infinity if(a.infinity && b.infinity && a.sign==b.sign) return true; if(!a.infinity && !b.infinity && a.sign==b.sign && a.exponent==b.exponent && a.fraction==b.fraction) return true; return a<b; }
bool operator < (const ieee_floatt &a, const ieee_floatt &b) { if(a.NaN || b.NaN) return false; // check both zero? if(a.is_zero() && b.is_zero()) return false; // one of them zero? if(a.is_zero()) return !b.sign; else if(b.is_zero()) return a.sign; // check sign if(a.sign!=b.sign) return a.sign; // handle infinity if(a.infinity) { if(b.infinity) return false; else return a.sign; } else if(b.infinity) return !a.sign; // check exponent if(a.exponent!=b.exponent) { if(a.sign) // both negative return a.exponent>b.exponent; else return a.exponent<b.exponent; } // check significand if(a.sign) // both negative return a.fraction>b.fraction; else return a.fraction<b.fraction; }
bool ieee_floatt::operator<=(const ieee_floatt &other) const { if(NaN_flag || other.NaN_flag) return false; // check zero if(is_zero() && other.is_zero()) return true; // handle infinity if(infinity_flag && other.infinity_flag && sign_flag==other.sign_flag) return true; if(!infinity_flag && !other.infinity_flag && sign_flag==other.sign_flag && exponent==other.exponent && fraction==other.fraction) return true; return *this<other; }