-
Notifications
You must be signed in to change notification settings - Fork 1
/
bigint.h
92 lines (62 loc) · 3.23 KB
/
bigint.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
#ifndef BIGINT_H
#define BIGINT_H
#include <iostream>
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdlib>
using namespace std;
namespace BigInt_Yo
{
class BigInt
{
public:
BigInt(); //default constructor
//postcondition : the private member pointer bigInteger points to NULL. the private member length sets to 0.
//BigInt(char arr[]);
BigInt(int integer); //constructor for integer
//precondition : integer is an integer.
//postcondition : the private member pointer bigInteger points to a dynamic array. the private member length sets to the length of integer.
BigInt(const BigInt &iniObj); //copy constructor
//precondition : iniObj is a BigInt type object.
//postcondition : copy the iniObj to the calling object.
BigInt(string stringOfNumber); //constructor for string
//precondition : stringOfNumber is a string.
//postcondition : the private member pointer bigInteger points to a dynamic array. the private member length sets to the length of stringOfNumber.
~BigInt(); //destructor
//postcondition : delete the dynamic array that bigInteger points to, then points to NULL.
int getLength();
char* getBigint();
int getSign();
//int& operator [](int a);
BigInt& operator =(const BigInt &rtSide); //assignment overloading
//precondition : rtSide is a BigInt type object.
//postcondition : assign the object rtSide to calling object.
friend const BigInt operator +(const BigInt &a, const BigInt &b); //operator plus overloading
//precondition : a and b are BigInt type object.
//postcondition : return the result of a + b.
friend const BigInt operator -(const BigInt &a, const BigInt &b); //operator minus overloading
//precondition : a and b are BigInt type object.
//postcondition : return the result of a - b.
friend const BigInt operator -(const BigInt &a);
friend const BigInt operator *(const BigInt &a, const BigInt &b);
friend const BigInt operator /(const BigInt &a, const BigInt &b);
friend const BigInt operator %(const BigInt &a, const BigInt &b);
friend ostream& operator <<(ostream& outputstream, const BigInt &a); //cout overloading
//precondition : outputstream is a ostream type object. a is a BigInt type object.
//postcondition : cout the bigInteger of a.
friend istream& operator >>(istream& inputstream, BigInt& a);
const BigInt factorial(string factor);
friend bool operator !=(const BigInt& a, const BigInt& b);
friend bool operator ==(const BigInt& a, const BigInt& b);
friend bool operator >=(const BigInt& a, const BigInt& b);
friend bool operator >(const BigInt& a, const BigInt& b);
friend bool operator <=(const BigInt& a, const BigInt& b);
friend bool operator <(const BigInt& a, const BigInt& b);
private:
char* bigInteger; //points to a dynamic array
int length; //the length of an array bigInteger points to
int sign;
};
}
#endif // BIGINT_H