abacus: bignum: add unary operators
This commit is contained in:
parent
7c1b3d302e
commit
0a5fb471e4
3 changed files with 29 additions and 0 deletions
|
|
@ -10,6 +10,16 @@ class BigNum {
|
|||
public:
|
||||
explicit BigNum(std::int64_t number);
|
||||
|
||||
friend BigNum operator+(BigNum const& rhs) {
|
||||
return rhs;
|
||||
}
|
||||
|
||||
friend BigNum operator-(BigNum const& rhs) {
|
||||
auto ret = rhs;
|
||||
ret.flip_sign();
|
||||
return ret;
|
||||
}
|
||||
|
||||
friend bool operator==(BigNum const& lhs, BigNum const& rhs) {
|
||||
return lhs.equal(rhs);
|
||||
}
|
||||
|
|
@ -35,6 +45,8 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
void flip_sign();
|
||||
|
||||
bool equal(BigNum const& rhs) const;
|
||||
bool less_than(BigNum const& rhs) const;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue