From 93fc1aee4125b6d7afc19deb7d90b51ec9d5259f Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Sun, 4 Apr 2021 21:39:00 +0100 Subject: [PATCH] Add Gmpq::is_zero() --- Number_types/include/CGAL/GMP/Gmpq_type.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Number_types/include/CGAL/GMP/Gmpq_type.h b/Number_types/include/CGAL/GMP/Gmpq_type.h index 451d2b00cdd..472fece35c1 100644 --- a/Number_types/include/CGAL/GMP/Gmpq_type.h +++ b/Number_types/include/CGAL/GMP/Gmpq_type.h @@ -228,6 +228,12 @@ public: double to_double() const noexcept; Sign sign() const noexcept; + bool is_zero() const + { + const __mpz_struct* zn = mpq_numref(mpq()); + return mpn_zero_p(zn->_mp_d, zn->_mp_size); + } + const mpq_t & mpq() const noexcept { return Ptr()->mpQ; } mpq_t & mpq() noexcept { return ptr()->mpQ; }