コード例 #1
0
ファイル: mpz.py プロジェクト: sn6uv/gmpy_cffi
 def __cmp(self, other):
     if isinstance(other, mpz):
         res = gmp.mpz_cmp(self._mpz, other._mpz)
     elif isinstance(other, (int, long)):
         if 0 <= other <= MAX_UI:
             res = gmp.mpz_cmp_ui(self._mpz, other)
         else:
             oth = _new_mpz()
             _pylong_to_mpz(other, oth)
             res = gmp.mpz_cmp(self._mpz, oth)
             _del_mpz(oth)
     elif isinstance(other, float):
         res = gmp.mpz_cmp_d(self._mpz, other)
     else:
         return None
     return res
コード例 #2
0
 def __cmp(self, other):
     if isinstance(other, mpz):
         res = gmp.mpz_cmp(self._mpz, other._mpz)
     elif isinstance(other, (int, long)):
         if 0 <= other <= MAX_UI:
             res = gmp.mpz_cmp_ui(self._mpz, other)
         else:
             oth = _new_mpz()
             _pylong_to_mpz(other, oth)
             res = gmp.mpz_cmp(self._mpz, oth)
             _del_mpz(oth)
     elif isinstance(other, float):
         res = gmp.mpz_cmp_d(self._mpz, other)
     else:
         return None
     return res
コード例 #3
0
ファイル: mpz.py プロジェクト: sn6uv/gmpy_cffi
 def __nonzero__(self):
     return gmp.mpz_cmp_ui(self._mpz, 0) != 0
コード例 #4
0
 def __nonzero__(self):
     return gmp.mpz_cmp_ui(self._mpz, 0) != 0