#include <number.h>
Definition at line 21 of file number.h.
◆ Number() [1/3]
Definition at line 23 of file number.h.
23 : type(
INT), value(0) { }
◆ Number() [2/3]
Number::Number |
( |
const int |
val | ) |
|
|
inline |
Definition at line 24 of file number.h.
24 : type(
INT), value(val) { }
◆ Number() [3/3]
Number::Number |
( |
const double |
val | ) |
|
|
inline |
◆ operator%()
Definition at line 169 of file number.cpp.
170 if (type ==
INT && rhs.type ==
INT) {
171 if (rhs.value.
i == 0) {
174 return Number(value.
i % rhs.value.
i);
◆ operator%=()
◆ operator*()
Definition at line 138 of file number.cpp.
139 if (type ==
INT && rhs.type ==
INT) {
140 return Number(value.
i * rhs.value.
i);
141 }
else if (type ==
FLOAT && rhs.type ==
FLOAT) {
142 return Number(value.
f * rhs.value.
f);
143 }
else if (type ==
INT && rhs.type ==
FLOAT) {
144 return Number(value.
i * rhs.value.
f);
145 }
else if (type ==
FLOAT && rhs.type ==
INT) {
146 return Number(value.
f * rhs.value.
i);
◆ operator*=()
◆ operator+()
Definition at line 110 of file number.cpp.
111 if (type ==
INT && rhs.type ==
INT) {
112 return Number(value.
i + rhs.value.
i);
113 }
else if (type ==
FLOAT && rhs.type ==
FLOAT) {
114 return Number(value.
f + rhs.value.
f);
115 }
else if (type ==
INT && rhs.type ==
FLOAT) {
116 return Number(value.
i + rhs.value.
f);
117 }
else if (type ==
FLOAT && rhs.type ==
INT) {
118 return Number(value.
f + rhs.value.
i);
◆ operator+=()
◆ operator-() [1/2]
Definition at line 124 of file number.cpp.
125 if (type ==
INT && rhs.type ==
INT) {
126 return Number(value.
i - rhs.value.
i);
127 }
else if (type ==
FLOAT && rhs.type ==
FLOAT) {
128 return Number(value.
f - rhs.value.
f);
129 }
else if (type ==
INT && rhs.type ==
FLOAT) {
130 return Number(value.
i - rhs.value.
f);
131 }
else if (type ==
FLOAT && rhs.type ==
INT) {
132 return Number(value.
f - rhs.value.
i);
◆ operator-() [2/2]
Number Number::operator- |
( |
| ) |
const |
◆ operator-=()
◆ operator/()
Definition at line 152 of file number.cpp.
153 if (type ==
INT && rhs.type ==
INT) {
154 if (rhs.value.
i == 0) {
157 return Number(value.
i / rhs.value.
i);
158 }
else if (type ==
FLOAT && rhs.type ==
FLOAT) {
159 return Number(value.
f / rhs.value.
f);
160 }
else if (type ==
INT && rhs.type ==
FLOAT) {
161 return Number(value.
i / rhs.value.
f);
162 }
else if (type ==
FLOAT && rhs.type ==
INT) {
163 return Number(value.
f / rhs.value.
i);
◆ operator/=()
◆ operator=()
◆ operator^()
Definition at line 180 of file number.cpp.
181 if (type ==
INT && rhs.type ==
INT) {
182 return Number((
int) pow(value.
i, rhs.value.
i));
183 }
else if (type ==
FLOAT && rhs.type ==
FLOAT) {
184 return Number(pow(value.
f, rhs.value.
f));
185 }
else if (type ==
INT && rhs.type ==
FLOAT) {
186 return Number(pow(value.
i, rhs.value.
f));
187 }
else if (type ==
FLOAT && rhs.type ==
INT) {
188 return Number(pow(value.
f, rhs.value.
i));
◆ operator^=()
◆ operator!=
◆ operator<
Definition at line 38 of file number.cpp.
39 if (lhs.type ==
INT && rhs.type ==
INT) {
40 return lhs.value.
i < rhs.value.
i;
41 }
else if (lhs.type ==
FLOAT && rhs.type ==
FLOAT) {
42 return lhs.value.
f < rhs.value.
f;
43 }
else if (lhs.type ==
INT && rhs.type ==
FLOAT) {
44 return lhs.value.
i < rhs.value.
f;
45 }
else if (lhs.type ==
FLOAT && rhs.type ==
INT) {
46 return lhs.value.
f < rhs.value.
i;
◆ operator<<
ostream& operator<< |
( |
ostream & |
out, |
|
|
const Number & |
num |
|
) |
| |
|
friend |
Definition at line 10 of file number.cpp.
11 if (num.type ==
INT) {
12 return out << num.value.
i;
13 }
else if (num.type ==
FLOAT) {
14 return out << fixed << num.value.
f;
◆ operator<=
◆ operator==
Definition at line 20 of file number.cpp.
21 if (lhs.type ==
INT && rhs.type ==
INT) {
22 return lhs.value.
i == rhs.value.
i;
23 }
else if (lhs.type ==
FLOAT && rhs.type ==
FLOAT) {
24 return lhs.value.
f == rhs.value.
f;
25 }
else if (lhs.type ==
INT && rhs.type ==
FLOAT) {
26 return lhs.value.
i == rhs.value.
f;
27 }
else if (lhs.type ==
FLOAT && rhs.type ==
INT) {
28 return lhs.value.
f == rhs.value.
i;
◆ operator>
Definition at line 52 of file number.cpp.
53 if (lhs.type ==
INT && rhs.type ==
INT) {
54 return lhs.value.
i > rhs.value.
i;
55 }
else if (lhs.type ==
FLOAT && rhs.type ==
FLOAT) {
56 return lhs.value.
f > rhs.value.
f;
57 }
else if (lhs.type ==
INT && rhs.type ==
FLOAT) {
58 return lhs.value.
i > rhs.value.
f;
59 }
else if (lhs.type ==
FLOAT && rhs.type ==
INT) {
60 return lhs.value.
f > rhs.value.
i;
◆ operator>=
The documentation for this class was generated from the following files: