29 #ifndef BIG_INTEGER_BASE_HEADER_GUARD
30 #define BIG_INTEGER_BASE_HEADER_GUARD
46 template <
typename T_Impl>
52 friend typename T_Impl::RandomGeneratorImpl;
79 BigIntegerBase (
const double input,
const unsigned int numberOfDigits,
const bool truncate =
false);
226 bool operator== (
const unsigned long input)
const;
230 bool operator== (
const unsigned int input)
const;
237 bool operator!= (
const unsigned long input)
const;
241 bool operator!= (
const unsigned int input)
const;
244 bool operator< (const BigIntegerBase<T_Impl> &input)
const;
248 bool operator< (
const unsigned long input)
const;
252 bool operator< (
const unsigned int input)
const;
255 bool operator<= (const BigIntegerBase<T_Impl> &input)
const;
259 bool operator<= (
const unsigned long input)
const;
263 bool operator<= (
const unsigned int input)
const;
270 bool operator>= (
const unsigned long input)
const;
274 bool operator>= (
const unsigned int input)
const;
281 bool operator> (
const unsigned long input)
const;
285 bool operator> (
const unsigned int input)
const;
324 int GetBit (
const size_t index)
const;
327 size_t GetSize (
const unsigned int base = 2)
const;
403 std::string
ToString (
const unsigned int base = 2)
const;
412 typename T_Impl::BigIntegerType
data;
418 template <
typename T_Impl>
421 template <
typename T_Impl>
424 template <
typename T_Impl>
427 template <
typename T_Impl>
431 template <
typename T_Impl>
434 template <
typename T_Impl>
437 template <
typename T_Impl>
440 template <
typename T_Impl>
444 template <
typename T_Impl>
447 template <
typename T_Impl>
450 template <
typename T_Impl>
453 template <
typename T_Impl>
457 template <
typename T_Impl>
460 template <
typename T_Impl>
463 template <
typename T_Impl>
466 template <
typename T_Impl>
470 template <
typename T_Impl>
473 template <
typename T_Impl>
476 template <
typename T_Impl>
479 template <
typename T_Impl>
483 template <
typename T_Impl>
486 template <
typename T_Impl>
489 template <
typename T_Impl>
492 template <
typename T_Impl>
496 template <
typename T_Impl>
499 template <
typename T_Impl>
502 template <
typename T_Impl>
505 template <
typename T_Impl>
509 template <
typename T_Impl>
510 bool operator< (const long lhs, const BigIntegerBase<T_Impl> &rhs);
512 template <
typename T_Impl>
513 bool operator< (const unsigned long lhs, const BigIntegerBase<T_Impl> &rhs);
515 template <
typename T_Impl>
516 bool operator< (const int lhs, const BigIntegerBase<T_Impl> &rhs);
518 template <
typename T_Impl>
519 bool operator< (const unsigned int lhs, const BigIntegerBase<T_Impl> &rhs);
522 template <
typename T_Impl>
523 bool operator<= (const long lhs, const BigIntegerBase<T_Impl> &rhs);
525 template <
typename T_Impl>
526 bool operator<= (const unsigned long lhs, const BigIntegerBase<T_Impl> &rhs);
528 template <
typename T_Impl>
529 bool operator<= (const int lhs, const BigIntegerBase<T_Impl> &rhs);
531 template <
typename T_Impl>
532 bool operator<= (const unsigned int lhs, const BigIntegerBase<T_Impl> &rhs);
535 template <
typename T_Impl>
538 template <
typename T_Impl>
541 template <
typename T_Impl>
544 template <
typename T_Impl>
548 template <
typename T_Impl>
551 template <
typename T_Impl>
554 template <
typename T_Impl>
557 template <
typename T_Impl>
568 #endif//BIG_INTEGER_BASE_HEADER_GUARD
BigIntegerBase< T_Impl > & operator++()
Prefix increment unary operator.
BigIntegerBase< T_Impl > & operator--()
Prefix decrement unary operator.
friend T_Impl
The big number implementation requires access to the underlying data.
bool operator>=(const BigIntegerBase< T_Impl > &input) const
BigIntegerBase greater than or equal to binary operator.
BigIntegerBase< T_Impl > & SetBit(const size_t index)
Sets a bit in the current instance at the specified index.
bool operator<(const BigIntegerBase< T_Impl > &input) const
BigIntegerBase less than binary operator.
BigIntegerBase< T_Impl > operator*(const long lhs, const BigIntegerBase< T_Impl > &rhs)
long multiplication binary operator
int GetBit(const size_t index) const
Returns the bit specified by index.
BigIntegerBase< T_Impl > GetNextPrime() const
Computes the first prime greater than the current instance.
bool operator>(const BigIntegerBase< T_Impl > &input) const
BigIntegerBase greater than binary operator.
BigIntegerBase< T_Impl > operator~() const
One's complement unary operator.
std::string ToString(const unsigned int base=2) const
Convert to std::string in the specified base.
BigIntegerBase< T_Impl > operator>>(const unsigned long input) const
Bitwise right shift binary operator.
BigIntegerBase< T_Impl > GetPowModN(const BigIntegerBase< T_Impl > &power, const BigIntegerBase< T_Impl > &n) const
Computes the integer raised to the specified BigIntegerBase power modulo n.
BigIntegerBase< T_Impl > & operator-=(const BigIntegerBase< T_Impl > &input)
BigIntegerBase subtraction & assignment binary operator.
BigIntegerBase< T_Impl > & operator|=(const BigIntegerBase< T_Impl > &input)
Bitwise inclusive OR & assignment binary operator.
bool operator==(const long lhs, const BigIntegerBase< T_Impl > &rhs)
long equality binary operator
unsigned long ToUnsignedLong() const
Convert to unsigned long.
BigIntegerBase< T_Impl > & operator<<=(const unsigned long input)
Bitwise left shift & assignment binary operator.
BigIntegerBase< T_Impl > & operator&=(const BigIntegerBase< T_Impl > &input)
Bitwise AND & assignment binary operator.
BigIntegerBase< T_Impl > & operator>>=(const unsigned long input)
Bitwise right shift & assignment binary operator.
BigIntegerBase< T_Impl > operator&(const BigIntegerBase< T_Impl > &input) const
Bitwise AND binary operator.
bool operator>=(const long lhs, const BigIntegerBase< T_Impl > &rhs)
long greater than or equal binary operator
BigIntegerBase< T_Impl > operator<<(const unsigned long input) const
Bitwise left shift binary operator.
BigIntegerBase< T_Impl > & Abs()
Sets the current instance to its absolute value.
BigIntegerBase< T_Impl > & operator/=(const BigIntegerBase< T_Impl > &input)
BigIntegerBase division & assignment binary operator.
bool IsPrime() const
Tests if the current instance is a prime number.
BigIntegerBase< T_Impl > operator/(const BigIntegerBase< T_Impl > &input) const
BigIntegerBase division binary operator.
size_t GetSize(const unsigned int base=2) const
Gets the length of the integer in the specified base.
BigIntegerBase< T_Impl > operator%(const long lhs, const BigIntegerBase< T_Impl > &rhs)
long modulus binary operator
BigIntegerBase< T_Impl > operator-() const
Unary negation operator.
BigIntegerBase()
Default constructor.
BigIntegerBase< T_Impl > operator+() const
Unary plus operator.
static BigIntegerBase< T_Impl > Gcd(const BigIntegerBase< T_Impl > &lhs, const BigIntegerBase< T_Impl > &rhs)
Computes the greatest common divisor of lhs and rhs.
BigIntegerBase< T_Impl > & Pow(const BigIntegerBase< T_Impl > &power)
Raises the current instance to the specified BigIntegerBase power.
BigIntegerBase< T_Impl > operator|(const BigIntegerBase< T_Impl > &input) const
Bitwise inclusive OR binary operator.
BigIntegerBase< T_Impl > operator^(const BigIntegerBase< T_Impl > &input) const
Bitwise exclusive OR binary operator.
Implementation of class BigIntegerBase. To be included in big_integer_base.h.
T_Impl::BigIntegerType data
Implementation-defined big integer variable.
bool operator==(const BigIntegerBase< T_Impl > &input) const
BigIntegerBase equality binary operator.
BigIntegerBase< T_Impl > GetPow(const BigIntegerBase< T_Impl > &power) const
Computes the integer raised to the specified BigIntegerBase power.
BigIntegerBase< T_Impl > & operator^=(const BigIntegerBase< T_Impl > &input)
Bitwise exclusive OR & assignment binary operator.
bool operator!=(const long lhs, const BigIntegerBase< T_Impl > &rhs)
long inequality binary operator
BigIntegerBase< T_Impl > & PowModN(const BigIntegerBase< T_Impl > &power, const BigIntegerBase< T_Impl > &n)
Raises the current instance to the specified BigIntegerBase power modulo n.
BigIntegerBase< T_Impl > & operator*=(const BigIntegerBase< T_Impl > &input)
BigIntegerBase multiplication & assignment binary operator.
BigIntegerBase< T_Impl > & operator+=(const BigIntegerBase< T_Impl > &input)
BigIntegerBase addition & assignment binary operator.
BigIntegerBase< T_Impl > & operator=(const BigIntegerBase< T_Impl > &input)
BigIntegerBase assignment operator.
BigIntegerBase< T_Impl > GetAbs() const
Computes the absolute value of the current instance.
Template class which adds syntactic sugar to big integer operations.
BigIntegerBase< T_Impl > operator+(const long lhs, const BigIntegerBase< T_Impl > &rhs)
long addition binary operator
bool operator<=(const BigIntegerBase< T_Impl > &input) const
BigIntegerBase less than or equal to binary operator.
static void Swap(BigIntegerBase< T_Impl > &lhs, BigIntegerBase< T_Impl > &rhs)
Swaps lhs with rhs efficiently.
BigIntegerBase< T_Impl > operator*(const BigIntegerBase< T_Impl > &input) const
BigIntegerBase multiplication binary operator.
BigIntegerBase< T_Impl > operator-(const long lhs, const BigIntegerBase< T_Impl > &rhs)
long subtraction binary operator
~BigIntegerBase()
Destructor.
BigIntegerBase< T_Impl > GetInverseModN(const BigIntegerBase< T_Impl > &n) const
Computes the inverse modulo n.
BigIntegerBase< T_Impl > & operator%=(const BigIntegerBase< T_Impl > &input)
BigIntegerBase modulus & assignment binary operator.
bool operator!=(const BigIntegerBase< T_Impl > &input) const
BigIntegerBase inequality binary operator.
BigIntegerBase< T_Impl > & InvertModN(const BigIntegerBase< T_Impl > &n)
Inverts the current instance modulo n.
static BigIntegerBase< T_Impl > Lcm(const BigIntegerBase< T_Impl > &lhs, const BigIntegerBase< T_Impl > &rhs)
Computes the least common multiple of lhs and rhs.
BigIntegerBase< T_Impl > operator/(const long lhs, const BigIntegerBase< T_Impl > &rhs)
long division binary operator
bool operator>(const long lhs, const BigIntegerBase< T_Impl > &rhs)
long greater than binary operator
BigIntegerBase< T_Impl > operator%(const BigIntegerBase< T_Impl > &input) const
BigIntegerBase modulus binary operator.