- #ifndef BIGINT_INC
- #define BIGINT_INC
-
-
- #include <assert.h>
- #include <iostream>
- #include <list>
-
- #ifndef MAX
- #define MAX(a,b) ((a>b)?a:b)
- #endif
-
- #ifndef MIN
- #define MIN(a,b) ((a<b)?a:b)
- #endif
-
-
- class BigInt
- {
- public:
- typedef unsigned char Byte;
-
- BigInt();
- ~BigInt();
- BigInt(const BigInt & br);
- BigInt(unsigned int i);
-
- void operator = (const BigInt & br);
- void operator = (unsigned int i);
- void operator = (int i);
-
- BigInt operator * (const BigInt & br)const;
- BigInt operator * (unsigned int i)const;
- BigInt operator * (Byte b)const;
- BigInt operator + (unsigned int i)const;
- BigInt operator + (const BigInt & br)const;
- BigInt operator - (const BigInt & br)const;
- BigInt operator - ()const;
-
- BigInt operator << (unsigned int i) const;
-
- void operator *= (const BigInt & br);
- void operator *= (unsigned int i);
- void operator += (const BigInt & br);
- void operator += (unsigned int i);
- void operator -= (const BigInt & br);
- void operator -= (unsigned int i);
-
- void operator /= (const BigInt & br);
- void operator ++ ();
- void operator -- ();
-
- bool operator ==(const BigInt & br)const;
- bool operator !=(const BigInt & br)const;
- bool operator <(const BigInt & br)const;
- bool operator >(const BigInt & br)const;
- bool operator <=(const BigInt & br)const;
- bool operator >=(const BigInt & br)const;
-
- static void div(BigInt & q, BigInt & r, const BigInt & f, const BigInt & d);
- static BigInt gcd(BigInt & a, BigInt & b);
-
- void print(std::ostream & out)const;
-
- double to_double() const;
-
- static void test();
- private:
-
- std::list<Byte> data_;
- bool positiv_;
- };
- inline std::ostream & operator << (std::ostream & out, const BigInt & bi){
- bi.print(out);
- return out;
- }
- #endif
#ifndef BIGINT_INC
#define BIGINT_INC
#include <assert.h>
#include <iostream>
#include <list>
#ifndef MAX
#define MAX(a,b) ((a>b)?a:b)
#endif
#ifndef MIN
#define MIN(a,b) ((a<b)?a:b)
#endif
class BigInt
{
public:
typedef unsigned char Byte;
BigInt();
~BigInt();
BigInt(const BigInt & br);
BigInt(unsigned int i);
void operator = (const BigInt & br);
void operator = (unsigned int i);
void operator = (int i);
BigInt operator * (const BigInt & br)const;
BigInt operator * (unsigned int i)const;
BigInt operator * (Byte b)const;
BigInt operator + (unsigned int i)const;
BigInt operator + (const BigInt & br)const;
BigInt operator - (const BigInt & br)const;
BigInt operator - ()const;
BigInt operator << (unsigned int i) const;
void operator *= (const BigInt & br);
void operator *= (unsigned int i);
void operator += (const BigInt & br);
void operator += (unsigned int i);
void operator -= (const BigInt & br);
void operator -= (unsigned int i);
void operator /= (const BigInt & br);
void operator ++ ();
void operator -- ();
bool operator ==(const BigInt & br)const;
bool operator !=(const BigInt & br)const;
bool operator <(const BigInt & br)const;
bool operator >(const BigInt & br)const;
bool operator <=(const BigInt & br)const;
bool operator >=(const BigInt & br)const;
static void div(BigInt & q, BigInt & r, const BigInt & f, const BigInt & d);
static BigInt gcd(BigInt & a, BigInt & b);
void print(std::ostream & out)const;
double to_double() const;
static void test();
private:
std::list<Byte> data_;
bool positiv_;
};
inline std::ostream & operator << (std::ostream & out, const BigInt & bi){
bi.print(out);
return out;
}
#endif