Added more operations

This commit is contained in:
Robert 2020-07-19 17:01:23 +02:00
parent 971f13a59b
commit 6d15af8b86
3 changed files with 56 additions and 38 deletions

View file

@ -6,6 +6,9 @@
namespace gm3p
{
/**
* A wrapper for mpz_t
*/
class gInt
{
public:
@ -14,10 +17,8 @@ namespace gm3p
gInt(mpz_t init);
gInt(mpq_t init);
gInt(mpf_t init);
gInt(unsigned long int init);
gInt(long int init);
gInt(const char* init, int base);
gInt(double init);
gInt(const char* init, int base = 10);
// DESTRUCTOR
~gInt();
@ -28,6 +29,8 @@ namespace gm3p
gInt(gInt&& other);
// ARITHMETIC OPERATORS
friend gInt operator-(const gInt& value);
friend gInt operator+(const gInt& left, const gInt& right);
friend gInt operator-(const gInt& left, const gInt& right);
friend gInt operator*(const gInt& left, const gInt& right);
@ -38,8 +41,13 @@ namespace gm3p
gInt& operator*=(const gInt& right);
gInt& operator/=(const gInt& right);
friend gInt Mul2Exp(const gInt& value, const mp_bitcnt_t& exp);
friend gInt Neg(const gInt& value);
friend gInt Abs(const gInt& value);
// CONVERSION OPERATORS
operator long int() const;
operator mpz_t&();
unsigned long int ToUnsigned() const;
char* ToString(char* buf, int base) const;