-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBigInteger.h
59 lines (44 loc) · 1.67 KB
/
BigInteger.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
#ifndef BIG_INTEGER
#define BIG_INTEGER
#include "MyVector.h"
/*
* The BigInteger class is used to represent integers larger than 2^31.
* It manages to do this by storing one digit in each 'element' of the list.
* Do not edit this file.
* Make your own BigInteger.hpp file using MyVector.hpp as a syntax guide.
*/
class BigIntException: public exception
{
public:
virtual const char * what() const throw()
{
return "Enter a string only numeric characters!";
}
};
class BigInteger
{
private:
//Backend for the BigInt Implementation
MyVector<int> digit_vector;
//Stores whether the BigInt represents a positive or negative number
bool isNegative;
public:
// The Default Constructor instantiates an empty list, and defaults isNegative to false
BigInteger();
/* The string constructor builds a positive or negative BigInteger object from a string
* integer: A string representation of an integer. A valid input would look like this:
* "865000000000000000000001"
* throws: The above exception when an incorrect string is entered.
*/
BigInteger(std::string really_big_number);
// You can skip this one -- BigInteger has no dynamic members
// BigInteger & operator=(BigInteger source);
// You can skip this one -- BigInteger has no dynamic members
// Copy constructor
// BigInteger(BigInteger &source);
// Outputs your current BigInt value by returning it as a std::string.
std::string to_string();
};
BigInteger operator+(BigInteger &bi1, BigInteger &bi2);
BigInteger operator-(BigInteger &bi1, BigInteger &bi2);
#endif