summaryrefslogtreecommitdiff
path: root/includes/BigInt.h
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2013-08-11 08:02:17 +0200
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2013-08-11 08:50:42 +0200
commit5f866c4a4b44d39b827a99d82006fa2d375c0ba9 (patch)
treeec36b7ca3a260350fab344346cc5e8148d5b3559 /includes/BigInt.h
parenta702df0e6b2cf5d523a8db764d6523d868eba8df (diff)
Adding BigInts, based off libtomcrypto / libtommath.
Diffstat (limited to 'includes/BigInt.h')
-rw-r--r--includes/BigInt.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/includes/BigInt.h b/includes/BigInt.h
new file mode 100644
index 0000000..a74df6e
--- /dev/null
+++ b/includes/BigInt.h
@@ -0,0 +1,80 @@
+#pragma once
+
+#include <stdint.h>
+#include <Exceptions.h>
+#include <BString.h>
+
+namespace Balau {
+
+class BigInt {
+ public:
+ BigInt() throw(GeneralException);
+ BigInt(const BigInt &) throw (GeneralException);
+ BigInt(BigInt &&);
+ ~BigInt();
+
+ BigInt & operator=(const BigInt &) throw (GeneralException);
+
+ void set(uint64_t) throw (GeneralException);
+ void set(int64_t);
+ void set(uint32_t) throw (GeneralException);
+ void set(int32_t);
+ void set(double) throw (GeneralException);
+ void set(const String &, int radix = 10) throw (GeneralException);
+ void set2expt(int i) throw (GeneralException);
+
+ BigInt operator+(unsigned int) const throw (GeneralException);
+ BigInt operator+(const BigInt &) const throw (GeneralException);
+ BigInt operator-(unsigned int) const throw (GeneralException);
+ BigInt operator-(const BigInt &) const throw (GeneralException);
+ BigInt operator*(unsigned int) const throw (GeneralException);
+ BigInt operator*(const BigInt &) const throw (GeneralException);
+ BigInt operator/(const BigInt &) const throw (GeneralException);
+ BigInt operator%(const BigInt &) const throw (GeneralException);
+ BigInt operator<<(unsigned int) const throw (GeneralException);
+ BigInt operator>>(unsigned int) const;
+
+ BigInt & operator+=(unsigned int) throw (GeneralException);
+ BigInt & operator+=(const BigInt &) throw (GeneralException);
+ BigInt & operator-=(unsigned int) throw (GeneralException);
+ BigInt & operator-=(const BigInt &) throw (GeneralException);
+ BigInt & operator*=(unsigned int) throw (GeneralException);
+ BigInt & operator*=(const BigInt &) throw (GeneralException);
+ BigInt & operator/=(const BigInt &) throw (GeneralException);
+ BigInt & operator%=(const BigInt &) throw (GeneralException);
+ BigInt & operator<<=(unsigned int) throw (GeneralException);
+ BigInt & operator>>=(unsigned int);
+
+ BigInt operator-() const throw (GeneralException);
+
+ BigInt & operator++();
+ BigInt operator++(int);
+ BigInt & operator--();
+ BigInt operator--(int);
+
+ enum comp_t { LT, GT, EQ };
+ comp_t comp(const BigInt &) const throw (GeneralException);
+
+ BigInt & neg() throw (GeneralException);
+
+ BigInt sqrt() const throw (GeneralException);
+ BigInt & do_sqrt() throw (GeneralException);
+
+ BigInt gcd(const BigInt &) const throw (GeneralException);
+ BigInt lcm(const BigInt &) const throw (GeneralException);
+
+ bool operator==(const BigInt &) const;
+ bool operator!=(const BigInt &) const;
+ bool operator<=(const BigInt &) const;
+ bool operator>=(const BigInt &) const;
+ bool operator<(const BigInt &) const;
+ bool operator>(const BigInt &) const;
+
+ String toString(int radix = 10) const;
+ char * makeString(int radix = 10) const;
+
+ private:
+ void * m_bi = NULL;
+};
+
+};