Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
mpz我需要获取对象的绝对值,GMPY2但我找不到任何函数,例如abs(). 如何才能做到这一点?
mpz
GMPY2
abs()
mpz 对象提供__abs__,所以普通的abs作品:
__abs__
abs
>>> gmpy2.mpz(3) mpz(3) >>> abs(gmpy2.mpz(3)) mpz(3) >>> gmpy2.mpz(-3) mpz(-3) >>> abs(gmpy2.mpz(-3)) mpz(3)