Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //a bignum library written in C++, it can (in theory) calculate with 4 billion digit long numbers
- //this is mostly for demonstration purposes, if you need performance, use something like GNU arbitrary precision library
- //Implemented by: http://www.youtube.com/user/thecplusplusguy
- //this might be an older version, I have to check
- #ifndef BIGNUM_H
- #define BIGNUM_H
- #include <iostream>
- #include <cmath>
- #include <cstring>
- class bignum{
- int* num;
- int size;
- bool minus;
- void remainder();
- public:
- bignum();
- bignum(int);
- bignum(long);
- bignum(const bignum& b);
- bignum(const char* c);
- bignum(std::string& c);
- ~bignum();
- int getSize() const;
- int* getNum() const;
- int getNumSize() const;
- int numLength(int a);
- void allocate(int s);
- friend std::ostream& operator<<(std::ostream& os,const bignum& b);
- friend bignum& operator++(const bignum& bn);
- friend bignum& operator--(const bignum& bn);
- //compare
- bool operator==(const bignum& b) const;
- bool operator==(int n) const;
- bool operator==(const char* c) const;
- bool operator>(const bignum& b) const;
- bool operator>(int n) const;
- bool operator>(const char* c) const;
- bool operator<(const bignum& b) const;
- bool operator<(int n) const;
- bool operator<(const char* c) const;
- bool operator<=(const bignum& b) const;
- bool operator<=(int n) const;
- bool operator<=(const char* c) const;
- bool operator>=(const bignum& b) const;
- bool operator>=(int n) const;
- bool operator>=(const char* c) const;
- bool operator!=(const bignum& b) const;
- bool operator!=(int n) const;
- bool operator!=(const char* c) const;
- //operations
- bignum& operator=(int num);
- bignum& operator=(const char* c);
- bignum& operator=(const bignum& b);
- bignum operator+(int num);
- bignum operator+(const bignum& bn);
- bignum operator+(const char* c);
- bignum operator-(int num);
- bignum operator-(const bignum& bn);
- bignum operator-(const char* c);
- bignum operator*(int num);
- bignum operator*(const bignum& bn);
- bignum operator*(const char* c);
- bignum operator/(int num);
- bignum operator/(const bignum& bn);
- bignum operator/(const char* c);
- bignum operator%(int num);
- bignum operator%(const bignum& bn);
- bignum operator%(const char* c);
- bignum& operator/=(int num);
- bignum& operator/=(const bignum& bn);
- bignum& operator/=(const char* c);
- bignum& operator+=(int num);
- bignum& operator+=(const bignum& bn);
- bignum& operator+=(const char* c);
- bignum& operator-=(int num);
- bignum& operator-=(const bignum& bn);
- bignum& operator-=(const char* c);
- bignum& operator*=(int num);
- bignum& operator*=(const bignum& bn);
- bignum& operator*=(const char* c);
- bignum& operator%=(int num);
- bignum& operator%=(const bignum& bn);
- bignum& operator%=(const char* c);
- bignum& operator++();
- bignum& operator--();
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement