-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHugeInteger_Ch_10.h
More file actions
71 lines (58 loc) · 3.09 KB
/
HugeInteger_Ch_10.h
File metadata and controls
71 lines (58 loc) · 3.09 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// 12191706 ±èÁ¤Áø
// HugeInteger class definition.
#pragma once
#ifndef HugeInteger_H
#define HugeInteger_H
#include <array>
#include <iostream>
#include <string>
class HugeInteger {
friend std::ostream& operator<<(std::ostream&, const HugeInteger&);
public:
static const int digits{ 40 }; // maximum digits in a HugeInteger;
HugeInteger(long = 0); // conversion/default constructor
HugeInteger(const std::string&); // conversion constructor
// addition operators;
HugeInteger operator+(const HugeInteger&) const; // HugeInteger + HugeInteger
HugeInteger operator+(int) const; // HugeInteger + int
HugeInteger operator+(const std::string&) const; // HugeInteger + string that represents large integer value
// minus operators;
HugeInteger operator-(const HugeInteger&) const; // HugeInteger + HugeInteger
HugeInteger operator-(int) const; // HugeInteger + int
HugeInteger operator-(const std::string&) const; // HugeInteger + string that represents large integer value
// multiplication operators;
HugeInteger operator*(const HugeInteger&) const; // HugeInteger * HugeInteger
HugeInteger operator*(int) const; // HugeInteger * int
HugeInteger operator*(const std::string&) const; // HugeInteger * string that represents large integer value
// division operators;
HugeInteger operator/(const HugeInteger&) const; // HugeInteger / HugeInteger
HugeInteger operator/(int) const; // HugeInteger / int
HugeInteger operator/(const std::string&) const; // HugeInteger / string that represents large integer value
// equality operators;
bool operator==(const HugeInteger&) const; // HugeInteger == HugeInteger
bool operator==(int) const; // HugeInteger == int
bool operator==(const std::string&) const; // HugeInteger == string that represents large integer value
// Not equality operators;
bool operator!=(const HugeInteger&) const; // HugeInteger != HugeInteger
bool operator!=(int) const; // HugeInteger != int
bool operator!=(const std::string&) const; // HugeInteger != string that represents large integer value
// greater than operators;
bool operator>(const HugeInteger&) const; // HugeInteger > HugeInteger
bool operator>(int) const; // HugeInteger > int
bool operator>(const std::string&) const; // HugeInteger > string that represents large integer value
// less than operators;
bool operator<(const HugeInteger&) const; // HugeInteger < HugeInteger
bool operator<(int) const; // HugeInteger < int
bool operator<(const std::string&) const; // HugeInteger < string that represents large integer value
// greater than and equal operators;
bool operator>=(const HugeInteger&) const; // HugeInteger >= HugeInteger
bool operator>=(int) const; // HugeInteger >= int
bool operator>=(const std::string&) const; // HugeInteger >= string that represents large integer value
// less than and equal operators;
bool operator<=(const HugeInteger&) const; // HugeInteger <= HugeInteger
bool operator<=(int) const; // HugeInteger <= int
bool operator<=(const std::string&) const; // HugeInteger <= string that represents large integer value
private:
std::array<short, digits> integer{}; // default init to 0s
};
#endif