2019-07-07 18:37:20 +03:00
|
|
|
//#
|
|
|
|
//# Copyright (C) 2018-2019 QuasarApp.
|
|
|
|
//# Distributed under the lgplv3 software license, see the accompanying
|
|
|
|
//# Everyone is permitted to copy and distribute verbatim copies
|
|
|
|
//# of this license document, but changing it is not allowed.
|
|
|
|
//#
|
|
|
|
|
|
|
|
|
2019-07-07 18:28:48 +03:00
|
|
|
#ifndef BIGINT_H
|
|
|
|
#define BIGINT_H
|
|
|
|
#include "mini-gmp.h"
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2019-07-07 18:37:20 +03:00
|
|
|
#include "minigmp_global.h"
|
2019-07-07 18:28:48 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The BigInt class - c++ minigmp wrapper
|
|
|
|
*/
|
|
|
|
|
2019-07-07 18:37:20 +03:00
|
|
|
class UNTITLEDSHARED_EXPORT BigInt
|
2019-07-07 18:28:48 +03:00
|
|
|
{
|
|
|
|
mpz_t data;
|
|
|
|
public:
|
|
|
|
BigInt();
|
|
|
|
BigInt(const BigInt& val );
|
|
|
|
BigInt(const char *str, int base = 10);
|
|
|
|
BigInt(std::string imput, int base = 10);
|
|
|
|
BigInt(int val);
|
|
|
|
BigInt(unsigned int val);
|
|
|
|
BigInt(double val);
|
|
|
|
|
|
|
|
std::string getString(int base = 10) const;
|
|
|
|
~BigInt();
|
|
|
|
|
|
|
|
friend BigInt operator + ( BigInt left, const BigInt& right);
|
|
|
|
friend BigInt operator + ( BigInt left, unsigned int right);
|
2019-07-07 21:10:53 +03:00
|
|
|
friend BigInt operator + ( BigInt left, int right);
|
|
|
|
|
2019-07-07 18:28:48 +03:00
|
|
|
friend BigInt& operator += ( BigInt &left, unsigned int right);
|
|
|
|
friend BigInt& operator += ( BigInt &left, const BigInt& right);
|
|
|
|
|
|
|
|
friend BigInt operator - ( BigInt left, const BigInt& right);
|
|
|
|
friend BigInt operator - (unsigned int right, BigInt left);
|
|
|
|
friend BigInt operator - ( BigInt left, unsigned int right);
|
2019-07-07 21:10:53 +03:00
|
|
|
friend BigInt operator - ( BigInt left, int right);
|
2019-07-07 18:28:48 +03:00
|
|
|
friend BigInt& operator -= ( BigInt &left, unsigned int right);
|
|
|
|
friend BigInt& operator -= ( BigInt &left, const BigInt& right);
|
|
|
|
|
|
|
|
|
|
|
|
friend BigInt operator / ( BigInt left, const BigInt& right);
|
|
|
|
friend BigInt operator / ( BigInt left, unsigned int right);
|
2019-07-07 21:10:53 +03:00
|
|
|
friend BigInt operator / ( BigInt left, int right);
|
|
|
|
|
2019-07-07 18:28:48 +03:00
|
|
|
friend BigInt& operator /= ( BigInt &left, unsigned int right);
|
|
|
|
friend BigInt& operator /= ( BigInt &left, const BigInt& right);
|
|
|
|
|
|
|
|
|
|
|
|
friend BigInt operator * ( BigInt left, const BigInt& right);
|
|
|
|
friend BigInt operator * ( BigInt left, unsigned int right);
|
|
|
|
friend BigInt operator * ( BigInt left, int right);
|
|
|
|
friend BigInt& operator *= ( BigInt &left, unsigned int right);
|
|
|
|
friend BigInt& operator *= ( BigInt &left, const BigInt& right);
|
|
|
|
friend BigInt& operator *= ( BigInt &left, int right);
|
|
|
|
|
|
|
|
|
|
|
|
friend BigInt operator % ( BigInt left, const BigInt& right);
|
|
|
|
friend BigInt operator % ( BigInt left, unsigned int right);
|
2019-07-07 21:10:53 +03:00
|
|
|
friend BigInt operator % ( BigInt left, int right);
|
|
|
|
|
|
|
|
|
2019-07-07 18:28:48 +03:00
|
|
|
friend BigInt& operator %= ( BigInt &left, unsigned int right);
|
|
|
|
friend BigInt& operator %= ( BigInt &left, const BigInt& right);
|
|
|
|
|
|
|
|
|
|
|
|
friend bool operator == ( const BigInt& left, const BigInt& right);
|
|
|
|
friend bool operator != ( const BigInt& left, const BigInt& right);
|
2019-07-07 21:10:53 +03:00
|
|
|
friend bool operator == ( const BigInt& left, int right); //to do
|
|
|
|
friend bool operator != ( const BigInt& left, int right); //to do
|
|
|
|
|
2019-07-07 18:28:48 +03:00
|
|
|
|
|
|
|
friend bool operator < ( const BigInt& left, const BigInt& right);
|
|
|
|
friend bool operator > ( const BigInt& left, const BigInt& right);
|
2019-07-07 21:10:53 +03:00
|
|
|
friend bool operator < ( const BigInt& left, int right);
|
|
|
|
friend bool operator > ( const BigInt& left, int right);
|
|
|
|
|
2019-07-07 18:28:48 +03:00
|
|
|
|
|
|
|
friend bool operator <= ( const BigInt& left, const BigInt& right);
|
|
|
|
friend bool operator >= ( const BigInt& left, const BigInt& right);
|
2019-07-07 21:10:53 +03:00
|
|
|
friend bool operator <= ( const BigInt& left, int right);
|
|
|
|
friend bool operator >= ( const BigInt& left, int right);
|
|
|
|
|
|
|
|
friend bool operator!(const BigInt& val);
|
|
|
|
|
|
|
|
friend BigInt operator << ( BigInt left, const BigInt& right);
|
|
|
|
friend BigInt operator << ( BigInt left, unsigned int right);
|
|
|
|
friend BigInt operator << ( BigInt left, int right);
|
|
|
|
|
|
|
|
friend BigInt& operator <<= ( BigInt &left, unsigned int right);
|
|
|
|
friend BigInt& operator <<= ( BigInt &left, const BigInt& right);
|
|
|
|
|
|
|
|
friend BigInt operator >> ( BigInt left, const BigInt& right);
|
|
|
|
friend BigInt operator >> ( BigInt left, unsigned int right);
|
|
|
|
friend BigInt& operator >>= ( BigInt &left, unsigned int right);
|
|
|
|
friend BigInt& operator >>= ( BigInt &left, const BigInt& right);
|
|
|
|
|
|
|
|
BigInt& operator-- ();
|
|
|
|
BigInt& operator++ ();
|
|
|
|
|
|
|
|
friend BigInt& operator~ (BigInt& val);
|
|
|
|
operator bool() const;
|
2019-07-07 18:28:48 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BIGINT_H
|