-
Notifications
You must be signed in to change notification settings - Fork 0
/
BigInt.hpp
113 lines (74 loc) · 2.96 KB
/
BigInt.hpp
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
105
106
107
108
109
110
111
112
113
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include "LinkedList.cpp"
#ifndef BIGINT_HPP
#define BIGINT_HPP
using namespace std;
class BigInt{
private:
LinkedList<int>* num;
/// @brief recuresive function to test if a number is greater than another
/// @param n number to test
/// @param index index of the test
/// @return true or false depending on the number comparison
bool rec_inf(const BigInt& n, int index) const;
public:
BigInt();
BigInt(int n);
BigInt(const BigInt& n);
BigInt(long int n);
~BigInt();
const string toString() const;
const string debugToString() const;
BigInt operator + (const BigInt& n) const;
BigInt operator + (long n) const;
BigInt operator - (const BigInt& n) const;
BigInt operator - (long n) const;
BigInt operator * (const BigInt& n) const;
BigInt operator * (long n) const;
/// @brief if a number is less than 0 or greater than 9, change it between 0-9 to fit in the cell and add or subtract to the next cells
/// @return if changes has been made
bool tidy();
bool operator < (const BigInt& n) const;
bool operator < (long n) const;
bool operator == (const BigInt& n) const;
bool operator == (long n) const;
bool operator != (const BigInt& n) const;
bool operator != (long n) const;
bool operator > (const BigInt& n) const;
bool operator > (long n) const;
bool operator >= (const BigInt& n) const;
bool operator >= (long n) const;
bool operator <=(const BigInt& n) const;
bool operator <=(long n) const;
BigInt operator % (const BigInt& n) const;
BigInt operator % (long n) const;
BigInt operator / (const BigInt& n) const;
BigInt operator / (long n) const;
BigInt& operator = (const BigInt& n);
BigInt& operator = (long n);
void operator *= (const BigInt& n);
void operator *= (long n);
void operator /= (const BigInt& n);
void operator /= (long n);
void operator -= (const BigInt& n);
void operator -= (long n);
void operator += (const BigInt& n);
void operator += (long n);
/// @brief get the factorial of a integer number
/// @param n number to get factorial
/// @return factorial result
static BigInt factorial(long n);
/// @brief fibonnacci value of a specific number
/// @param n terme to calculate
/// @return fibonnacci result
static BigInt fibonnacci(long n);
/// @brief check if the number is a palidrome (ex : 1536351)
/// @return true if palidrome, false otherwise
bool palindrome() const;
BigInt operator ^ (const BigInt& exp) const;
LinkedList<int> * getDigits() const;
};
#endif