mirror of https://github.com/CGAL/cgal
comparisons for MP_Float
This commit is contained in:
parent
8b79068a12
commit
a7ccc80f18
|
|
@ -27,6 +27,7 @@
|
|||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <boost/operators.hpp>
|
||||
|
||||
// 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<MP_Float
|
||||
#ifdef _MSC_VER
|
||||
, boost::equality_comparable2<MP_Float, int
|
||||
, boost::equality_comparable2<MP_Float, double
|
||||
> >
|
||||
#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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue