ht's Scheme Interpreter  1.0
a simplified scheme interpreter implementation
bigint.hpp
Go to the documentation of this file.
1 #ifndef __SCHEME_UTILITY_BIGINT
2 #define __SCHEME_UTILITY_BIGINT
3 #include <iosfwd>
4 #include <cstdint>
5 #include <vector>
6 #include <string>
7 #include <cstddef>
8 #include <utility>
9 
10 
11 class BigInt
12 {
13  private:
15  size_t len;
16  bool nonNeg;
17  bool isZero() const;
18  BigInt& rawPlus(const BigInt& b);
19  BigInt& rawMinus(const BigInt& b);
20  std::pair<BigInt&,BigInt> divandmod(const BigInt& b);
21  bool rawSmaller(const BigInt& b) const;
22  bool rawGreater(const BigInt& b) const;
23  BigInt& setSign(const bool sign);
24  public:
25  BigInt(long long num);
26  BigInt(const std::string& s);
27  BigInt();
28  BigInt& assign(long long num);
29  BigInt& assign(const std::string& s);
30  BigInt& operator += (const BigInt& b);
31  BigInt& operator -= (const BigInt& b);
32  BigInt& operator *= (const BigInt& b);
33  BigInt& operator /= (const BigInt& b);
34  BigInt& operator %= (const BigInt& b);
35  BigInt operator + (const BigInt& b) const;
36  BigInt operator - (const BigInt& b) const;
37  BigInt operator * (const BigInt& b) const;
38  BigInt operator / (const BigInt& b) const;
39  BigInt operator % (const BigInt& b) const;
40  BigInt operator - () const;
41  friend std::istream& operator >>(std::istream& i, BigInt& b);
42  friend std::ostream& operator <<(std::ostream& o, const BigInt& b);
43  bool operator > (const BigInt& b) const;
44  bool operator < (const BigInt& b) const;
45  bool operator == (const BigInt& b) const;
46  bool operator != (const BigInt& b) const;
47  bool operator >= (const BigInt& b) const;
48  bool operator <= (const BigInt& b) const;
49  template<typename CompareFunc> friend bool rawCompare(const BigInt& a, const BigInt& b);
50 
51 };
52 #endif
BigInt & operator/=(const BigInt &b)
Definition: bigint.cpp:353
std::pair< BigInt &, BigInt > divandmod(const BigInt &b)
Definition: bigint.cpp:315
BigInt & assign(long long num)
Definition: bigint.cpp:35
BigInt & operator%=(const BigInt &b)
Definition: bigint.cpp:364
BigInt(const std::string &s)
Definition: bigint.cpp:25
BigInt operator*(const BigInt &b) const
Definition: bigint.cpp:278
BigInt & operator-=(const BigInt &b)
Definition: bigint.cpp:235
bool operator>(const BigInt &b) const
Definition: bigint.cpp:133
bool operator<=(const BigInt &b) const
Definition: bigint.cpp:156
bool rawGreater(const BigInt &b) const
Definition: bigint.cpp:119
BigInt & rawPlus(const BigInt &b)
Definition: bigint.cpp:161
bool operator<(const BigInt &b) const
Definition: bigint.cpp:124
BigInt()
Definition: bigint.cpp:30
friend bool rawCompare(const BigInt &a, const BigInt &b)
Definition: bigint.cpp:104
BigInt(long long num)
Definition: bigint.cpp:20
size_t len
Definition: bigint.hpp:15
BigInt & operator+=(const BigInt &b)
Definition: bigint.cpp:202
bool operator>=(const BigInt &b) const
Definition: bigint.cpp:151
BigInt operator/(const BigInt &b) const
Definition: bigint.cpp:358
BigInt & operator*=(const BigInt &b)
Definition: bigint.cpp:303
BigInt & setSign(const bool sign)
Definition: bigint.cpp:309
BigInt & rawMinus(const BigInt &b)
Definition: bigint.cpp:182
BigInt operator-() const
Definition: bigint.cpp:95
bool isZero() const
Definition: bigint.cpp:15
bool operator!=(const BigInt &b) const
Definition: bigint.cpp:146
bool rawSmaller(const BigInt &b) const
Definition: bigint.cpp:114
BigInt operator%(const BigInt &b) const
Definition: bigint.cpp:370
std::vector< int32_t > d
Definition: bigint.hpp:14
BigInt operator+(const BigInt &b) const
Definition: bigint.cpp:264
bool operator==(const BigInt &b) const
Definition: bigint.cpp:138
BigInt operator-(const BigInt &b) const
Definition: bigint.cpp:271
bool nonNeg
Definition: bigint.hpp:16
BigInt & assign(const std::string &s)
Definition: bigint.cpp:56