diff --git a/Number_types/include/CGAL/MP_Float.h b/Number_types/include/CGAL/MP_Float.h index 56e22b7e39b..b0a161837c1 100644 --- a/Number_types/include/CGAL/MP_Float.h +++ b/Number_types/include/CGAL/MP_Float.h @@ -27,6 +27,7 @@ #include #include #include +#include // MP_Float : multiprecision scaled integers. @@ -106,7 +107,13 @@ MP_Float operator*(const MP_Float &a, const MP_Float &b); MP_Float operator%(const MP_Float &a, const MP_Float &b); -class MP_Float +class MP_Float : boost::totally_ordered1 > +#endif + > { public: typedef short limb; @@ -223,6 +230,20 @@ public: MP_Float& operator*=(const MP_Float &a) { return *this = *this * a; } MP_Float& operator%=(const MP_Float &a) { return *this = *this % a; } + friend bool operator<(const MP_Float &a, const MP_Float &b) + { return INTERN_MP_FLOAT::compare(a, b) == SMALLER; } + + friend bool operator==(const MP_Float &a, const MP_Float &b) + { return (a.v == b.v) && (a.v.empty() || (a.exp == b.exp)); } + +#ifdef _MSC_VER + // Needed because without /permissive-, it makes hidden friends visible (operator== from Quotient) + friend bool operator==(const MP_Float &a, int b) + { return a == MP_Float(b); } + friend bool operator==(const MP_Float &a, double b) + { return a == MP_Float(b); } +#endif + exponent_type max_exp() const { return exponent_type(v.size()) + exp; @@ -365,30 +386,6 @@ inline void swap(MP_Float &m, MP_Float &n) { m.swap(n); } -inline -bool operator<(const MP_Float &a, const MP_Float &b) -{ return INTERN_MP_FLOAT::compare(a, b) == SMALLER; } - -inline -bool operator>(const MP_Float &a, const MP_Float &b) -{ return b < a; } - -inline -bool operator>=(const MP_Float &a, const MP_Float &b) -{ return ! (a < b); } - -inline -bool operator<=(const MP_Float &a, const MP_Float &b) -{ return ! (a > b); } - -inline -bool operator==(const MP_Float &a, const MP_Float &b) -{ return (a.v == b.v) && (a.v.empty() || (a.exp == b.exp)); } - -inline -bool operator!=(const MP_Float &a, const MP_Float &b) -{ return ! (a == b); } - MP_Float approximate_sqrt(const MP_Float &d);