-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumber.hpp
More file actions
54 lines (39 loc) · 1.39 KB
/
Number.hpp
File metadata and controls
54 lines (39 loc) · 1.39 KB
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
#ifndef NUMBER
#define NUMBER
#include <bits/stdc++.h>
using namespace std;
class Number {
public:
vector<int> digits;
unsigned int base;
int exponent;
bool sign;
Number(vector<int> &dig, int b, int expo, bool sig = false);
Number(Number *n);
// removes zeroes from the Left and adjusts the exponent
void removeZeroes(bool maintain_exp=false, int exp=INT_MAX);
// add exponent
Number* addExponent(int e);
// print to see the number
void printNumber(int precision=INT_MAX);
// reverse digits
void rev();
// adjust for precision
void adjustForPrecision(int precision);
// express without decimal
// returns the power to be subtracted from the num or denom
int expressWihtoutDecimal();
// pad numbers to normalise exponents
// diffexp - (n1 - 1) + (n2 - 1)
// return exponent to be added
static int padNumbers(Number* A, Number* B);
// compare a number with current number
static int compare(Number* n1, Number* n2, bool considerSign = false);
// two
static Number* retTwo(int b, int expo = 0, bool sig = false);
// QuoRem
static pair<int, int> QuoRem(int temp, int base);
// make digits equal
static void makeDigitsEqual(Number* A, Number* B);
};
#endif // NUMBER