-
Notifications
You must be signed in to change notification settings - Fork 1
/
CGMPBigInt.h
65 lines (51 loc) · 2.06 KB
/
CGMPBigInt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once
#include "mini-gmp.h"
//#include "gmp.h"
#include <stdint.h>
#include <string>
class CGMPBigInt
{
public:
explicit CGMPBigInt();
explicit CGMPBigInt(const char * str);
explicit CGMPBigInt(const std::string & str);
CGMPBigInt(uint32_t value);
CGMPBigInt(int32_t value);
CGMPBigInt(uint64_t value);
CGMPBigInt(const CGMPBigInt & other);
~CGMPBigInt();
public:
CGMPBigInt& Add(const CGMPBigInt& other);
CGMPBigInt& Sub(const CGMPBigInt& other);
CGMPBigInt& Mul(const CGMPBigInt& other);
CGMPBigInt& Div(const CGMPBigInt& other);
CGMPBigInt& MulRate(float fRatio);
CGMPBigInt& DivRate(float fRatio);
void Set(const char * str);
CGMPBigInt &operator = (const CGMPBigInt & other);
CGMPBigInt &operator = (int32_t value);
friend CGMPBigInt operator + (const CGMPBigInt& a, const CGMPBigInt& b);
friend CGMPBigInt operator - (const CGMPBigInt& a, const CGMPBigInt& b);
friend CGMPBigInt operator * (const CGMPBigInt& a, const CGMPBigInt& b);
friend CGMPBigInt operator / (const CGMPBigInt& a, const CGMPBigInt& b);
friend CGMPBigInt operator % (const CGMPBigInt& a, const CGMPBigInt& b);
friend bool operator < (const CGMPBigInt& a, const CGMPBigInt& b);
friend bool operator > (const CGMPBigInt& a, const CGMPBigInt& b);
friend bool operator <= (const CGMPBigInt& a, const CGMPBigInt& b);
friend bool operator >= (const CGMPBigInt& a, const CGMPBigInt& b);
void Retrieve(char src[256]);
int ToString(char * str, int base = 10);
std::string ToString();
int ToInt();
unsigned int ToUint();
float GetFloatRate(const CGMPBigInt& other) const;
bool IsZero() const;
bool Equal(const CGMPBigInt& other) const;
bool BiggerOrEqual(const CGMPBigInt& other) const;
bool Bigger(const CGMPBigInt& other) const;
int Cmp(const CGMPBigInt& other) const ;
bool Smaller(const CGMPBigInt& other) const;
bool SmallerOrEqual(const CGMPBigInt& other) const;
private:
mpz_t m_value;
};