-
Notifications
You must be signed in to change notification settings - Fork 0
/
Number.hpp
56 lines (52 loc) · 1.6 KB
/
Number.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
#ifndef NUMBER_HPP
# define NUMBER_HPP
#include "utils.hpp"
#include "Symbol.hpp"
# define NUMBER_LIMIT 1000000
class Number : public Symbol
{
public:
class ModuloByZeroException : public exception
{
virtual const char* what() const throw();
};
class DivisionByZeroException : public exception
{
virtual const char* what() const throw();
};
class NotANumberException : public exception
{
virtual const char* what() const throw();
};
class NumberTooLongException : public exception
{
virtual const char* what() const throw();
};
class NegativePowerException : public exception
{
virtual const char* what() const throw();
};
Number();
Number(string const &data) throw(NotANumberException, NumberTooLongException);
~Number();
Number operator=(Number const &rhs);
Number operator+(Number const &rhs);
Number operator-(Number const &rhs);
bool operator>=(Number const &rhs);
bool operator>(Number const &rhs);
bool operator<=(Number const &rhs);
bool operator<(Number const &rhs);
bool operator==(Number const &rhs);
bool operator!=(Number const &rhs);
Number operator*(Number const &rhs);
Number operator/(Number const &rhs) throw(DivisionByZeroException);
Number operator%(Number const &rhs) throw(ModuloByZeroException);
Number operator^(Number power) throw(NegativePowerException);
string getValue() const;
private:
string _value;
};
ostream& operator<<(ostream &o, Number const &rhs);
Number karatsuba(Number a, Number b);
Number gcd(Number a, Number b);
#endif