fix Ec::operator<()

dev
MITSUNARI Shigeo 9 years ago
parent 2efd4a8fd6
commit 6b2745e011
  1. 4
      include/mcl/ec.hpp

@ -693,12 +693,15 @@ public:
sub(R, *this, rhs); // QQQ : optimized later sub(R, *this, rhs); // QQQ : optimized later
return R.isZero(); return R.isZero();
} }
bool operator!=(const EcT& rhs) const { return !operator==(rhs); }
bool operator<(const EcT& rhs) const bool operator<(const EcT& rhs) const
{ {
if (isZero()) { if (isZero()) {
return !rhs.isZero(); return !rhs.isZero();
} }
if (rhs.isZero()) return false; if (rhs.isZero()) return false;
normalize();
rhs.normalize();
int cmp = Fp::compare(x, rhs.x); int cmp = Fp::compare(x, rhs.x);
if (cmp < 0) return true; if (cmp < 0) return true;
if (cmp > 0) return false; if (cmp > 0) return false;
@ -707,7 +710,6 @@ public:
bool operator>=(const EcT& rhs) const { return !operator<(rhs); } bool operator>=(const EcT& rhs) const { return !operator<(rhs); }
bool operator>(const EcT& rhs) const { return rhs < *this; } bool operator>(const EcT& rhs) const { return rhs < *this; }
bool operator<=(const EcT& rhs) const { return !operator>(rhs); } bool operator<=(const EcT& rhs) const { return !operator>(rhs); }
bool operator!=(const EcT& rhs) const { return !operator==(rhs); }
private: private:
static inline void mulArray(EcT& z, const EcT& x, const fp::Unit *y, size_t yn, bool isNegative) static inline void mulArray(EcT& z, const EcT& x, const fp::Unit *y, size_t yn, bool isNegative)
{ {

Loading…
Cancel
Save