2020-07-18 21:06:17 +02:00
|
|
|
#pragma once
|
|
|
|
|
2020-07-18 22:47:00 +02:00
|
|
|
#include <iostream>
|
|
|
|
|
2020-07-18 21:06:17 +02:00
|
|
|
#include "gmp.h"
|
|
|
|
|
|
|
|
namespace gm3p
|
|
|
|
{
|
|
|
|
class gInt
|
|
|
|
{
|
|
|
|
public:
|
2020-07-18 22:47:00 +02:00
|
|
|
// CONSTRUCTORS
|
2020-07-18 21:06:17 +02:00
|
|
|
gInt();
|
|
|
|
gInt(mpz_t init);
|
2020-07-19 02:06:36 +02:00
|
|
|
gInt(mpq_t init);
|
|
|
|
gInt(mpf_t init);
|
2020-07-18 22:47:00 +02:00
|
|
|
gInt(unsigned long int init);
|
2020-07-18 21:06:17 +02:00
|
|
|
gInt(long int init);
|
|
|
|
gInt(const char* init, int base);
|
2020-07-19 02:06:36 +02:00
|
|
|
gInt(double init);
|
|
|
|
|
|
|
|
// DESTRUCTOR
|
2020-07-18 21:06:17 +02:00
|
|
|
~gInt();
|
|
|
|
|
2020-07-19 02:06:36 +02:00
|
|
|
// ASSIGNMENT/COPY OPERATORS
|
2020-07-18 21:06:17 +02:00
|
|
|
gInt& operator=(const gInt& other);
|
2020-07-19 02:06:36 +02:00
|
|
|
gInt(const gInt& other);
|
|
|
|
gInt(gInt&& other);
|
2020-07-18 21:06:17 +02:00
|
|
|
|
2020-07-18 22:47:00 +02:00
|
|
|
// ARITHMETIC OPERATORS
|
2020-07-18 21:06:17 +02:00
|
|
|
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);
|
|
|
|
friend gInt operator/(const gInt& left, const gInt& right);
|
|
|
|
|
2020-07-18 22:47:00 +02:00
|
|
|
gInt& operator+=(const gInt& right);
|
|
|
|
gInt& operator-=(const gInt& right);
|
|
|
|
gInt& operator*=(const gInt& right);
|
|
|
|
gInt& operator/=(const gInt& right);
|
|
|
|
|
2020-07-19 02:06:36 +02:00
|
|
|
// CONVERSION OPERATORS
|
|
|
|
operator long int() const;
|
|
|
|
|
|
|
|
unsigned long int ToUnsigned() const;
|
|
|
|
char* ToString(char* buf, int base) const;
|
|
|
|
double ToDouble() const;
|
|
|
|
double ToDouble(long int* exp) const;
|
|
|
|
|
|
|
|
// STDIO OPERATORS
|
2020-07-18 21:06:17 +02:00
|
|
|
friend std::ostream& operator<<(std::ostream& os, const gInt& value);
|
|
|
|
|
|
|
|
private:
|
|
|
|
mpz_t value;
|
|
|
|
};
|
|
|
|
}
|