-
Notifications
You must be signed in to change notification settings - Fork 10
/
BigIntegerWrapper.h
104 lines (73 loc) · 3.57 KB
/
BigIntegerWrapper.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// ///////////////////////////////////////////////////////////////// //
// *C++ 11 BigInteger Library
// *Copyright(c) 2018 Mbadiwe Nnaemeka Ronald
// *Github Repository <https://github.com/ron4fun>
// *Distributed under the MIT software license, see the accompanying file LICENSE
// *or visit http ://www.opensource.org/licenses/mit-license.php.
// *Acknowledgements:
// ** //
// *Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative
// *development of this library in Pascal/Delphi
// ////////////////////////////////////////////////////// ///////////////
#ifndef BIGINTEGERWRAPPER_H
#define BIGINTEGERWRAPPER_H
#include <memory>
#include <string>
#include <vector>
using namespace std;
class BigIntegerWrapper
{
public:
BigIntegerWrapper();
BigIntegerWrapper(const string &value, const int32_t radix = 10);
BigIntegerWrapper(const vector<uint8_t> &bytes, const int32_t sign = 1);
~BigIntegerWrapper();
BigIntegerWrapper(const BigIntegerWrapper &rhs);
BigIntegerWrapper& operator=(const BigIntegerWrapper &rhs);
BigIntegerWrapper Abs() const;
BigIntegerWrapper Add(const BigIntegerWrapper &value) const;
BigIntegerWrapper Subtract(const BigIntegerWrapper &value) const;
BigIntegerWrapper And(const BigIntegerWrapper &value) const;
BigIntegerWrapper Not() const;
BigIntegerWrapper AndNot(const BigIntegerWrapper &val) const;
BigIntegerWrapper Or(const BigIntegerWrapper &value) const;
BigIntegerWrapper Xor(const BigIntegerWrapper &value) const;
int32_t CompareTo(const BigIntegerWrapper &value) const;
BigIntegerWrapper Divide(const BigIntegerWrapper &value) const;
vector<BigIntegerWrapper> DivideAndRemainder(const BigIntegerWrapper &value) const;
BigIntegerWrapper Gcd(const BigIntegerWrapper &value) const;
BigIntegerWrapper Inc() const;
bool RabinMillerTest(const int32_t certainty, const bool randomlySelected = false) const;
bool IsProbablePrime(const int32_t certainty, const bool randomlySelected = false) const;
BigIntegerWrapper Max(const BigIntegerWrapper &value) const;
BigIntegerWrapper Min(const BigIntegerWrapper &value) const;
BigIntegerWrapper Mod(const BigIntegerWrapper &value) const;
BigIntegerWrapper ModInverse(const BigIntegerWrapper &value) const;
BigIntegerWrapper ModPow(BigIntegerWrapper &e, const BigIntegerWrapper &m) const;
BigIntegerWrapper Multiply(const BigIntegerWrapper &value) const;
BigIntegerWrapper Square() const;
BigIntegerWrapper Negate() const;
BigIntegerWrapper NextProbablePrime() const;
BigIntegerWrapper Pow(const int32_t exp) const;
BigIntegerWrapper Remainder(const BigIntegerWrapper &n) const;
BigIntegerWrapper ShiftLeft(const int32_t n) const;
BigIntegerWrapper ShiftRight(const int32_t n) const;
vector<uint8_t> ToByteArray() const;
vector<uint8_t> ToByteArrayUnsigned() const;
bool TestBit(const int32_t n) const;
BigIntegerWrapper SetBit(const int32_t n) const;
BigIntegerWrapper ClearBit(const int32_t n) const;
BigIntegerWrapper FlipBit(const int32_t n) const;
int32_t GetLowestSetBit() const;
bool Equals(const BigIntegerWrapper &other) const;
int32_t GetHashCode() const;
static int32_t BitCnt(const int32_t i);
static int32_t BitLen(const int32_t w);
static BigIntegerWrapper ProbablePrime(const int32_t BitLength);
static BigIntegerWrapper ValueOf(const int64_t value);
static BigIntegerWrapper Arbitrary(const int32_t sizeInBits);
string ToString(const int32_t radix = 10) const;
private:
void * ptr = nullptr;
};
#endif //BIGINTEGERWRAPPER_H