X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=src%2Fgmprat.h;h=b92d5af85c7263081496850603b7688251a67270;hb=63e9d774c858dfe79264a24ae8daa3dde3c7bb6e;hp=3e275d28a61e739b7650eb3a91e4b2f7d1b20667;hpb=67539822c80c8057d850b542abc142c189bd3f05;p=ipdf%2Fcode.git diff --git a/src/gmprat.h b/src/gmprat.h index 3e275d2..b92d5af 100644 --- a/src/gmprat.h +++ b/src/gmprat.h @@ -33,7 +33,7 @@ class Gmprat return "-" + operator-().Str(); } double p = Log10(); - if (isinf(p)) + if (std::isinf(p)) return "0"; int P = (int)p; @@ -103,6 +103,10 @@ class Gmprat Gmprat Abs() const {Gmprat a(*this); mpq_abs(a.m_op, a.m_op); return a;} + size_t Size() const + { + return sizeof(uint64_t) * (mpq_numref(m_op)->_mp_alloc + mpq_denref(m_op)->_mp_alloc); + } private: friend std::ostream& operator<<(std::ostream& os, const Gmprat & fith); @@ -115,7 +119,10 @@ inline std::ostream & operator<<(std::ostream & os, const Gmprat & fith) return os; } - +inline std::string Str(const Gmprat & g) {return g.Str();} +inline double Log10(const Gmprat & g) {return g.Log10();} +inline size_t Size(const Gmprat & g) {return g.Size();} +inline Gmprat Abs(const Gmprat & g) {return g.Abs();} #endif //_GMPRAT_H