aboutsummaryrefslogtreecommitdiff
path: root/bigint.h
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-10-03 22:15:25 +0200
committertomsmeding <tom.smeding@gmail.com>2016-10-03 22:15:25 +0200
commitd24ab714b958b9fece4631076e240739ad0dd23f (patch)
tree7d4d35dc7a7b2a03863b9a5bbde9382e14b7d1aa /bigint.h
parent2bf5effe95641667a1ed51c04eff7760f6a42ef4 (diff)
Progress
Diffstat (limited to 'bigint.h')
-rw-r--r--bigint.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/bigint.h b/bigint.h
index 6579054..213bf5c 100644
--- a/bigint.h
+++ b/bigint.h
@@ -39,6 +39,9 @@ public:
Bigint& operator+=(const Bigint&);
Bigint& operator-=(const Bigint&);
Bigint& operator*=(const Bigint&);
+ Bigint& operator+=(slongdigit_t);
+ Bigint& operator-=(slongdigit_t);
+ Bigint& operator*=(slongdigit_t);
Bigint& operator<<=(int);
Bigint& operator>>=(int);
Bigint& negate();
@@ -46,9 +49,12 @@ public:
Bigint operator+(const Bigint&) const;
Bigint operator-(const Bigint&) const;
Bigint operator*(const Bigint&) const;
+ Bigint operator+(slongdigit_t) const;
+ Bigint operator-(slongdigit_t) const;
+ Bigint operator*(slongdigit_t) const;
Bigint operator<<(int) const;
Bigint operator>>(int) const;
- std::pair<Bigint,Bigint> divmod(const Bigint&) const;
+ std::pair<Bigint,Bigint> divmod(const Bigint&) const; //rounds towards zero; returns {quotient,remainder}
bool operator==(const Bigint&) const;
bool operator!=(const Bigint&) const;
@@ -70,6 +76,8 @@ public:
int bitcount() const;
slongdigit_t lowdigits() const;
+ bool even() const;
+ bool odd() const;
std::vector<char> serialise() const;
void deserialise(const std::vector<char>&);
@@ -79,9 +87,12 @@ public:
friend std::ostream& operator<<(std::ostream&,Bigint);
digit_t _digit(int idx) const;
-};
-Bigint pow(const Bigint &b,const Bigint &ex);
+
+ static Bigint zero;
+ static Bigint one;
+ static Bigint mone;
+};
std::istream& operator>>(std::istream&,Bigint&);
std::ostream& operator<<(std::ostream&,Bigint);