29 #ifndef _cvc3__rational_h_
30 #define _cvc3__rational_h_
49 #ifdef _DEBUG_RATIONAL_
53 static int num_created = 0;
58 static int num_deleted = 0;
65 Rational(
const Impl& t);
71 Rational(
const Rational &n);
72 Rational(
const Unsigned& n);
73 Rational(
int n,
int d = 1);
74 Rational(
const char* n,
int base = 10);
75 Rational(
const std::string& n,
int base = 10);
76 Rational(
const char* n,
const char* d,
int base = 10);
77 Rational(
const std::string& n,
const std::string& d,
int base = 10);
82 Rational& operator=(
const Rational& n);
84 std::string toString(
int base = 10)
const;
100 friend CVC_DLL Rational operator%(
const Rational &n1,
const Rational &n2);
104 Rational &operator+=(
const Rational &n2);
105 Rational &operator-=(
const Rational &n2);
106 Rational &operator*=(
const Rational &n2);
107 Rational &operator/=(
const Rational &n2);
122 bool isInteger()
const;
126 bool isUnsigned()
const {
return (isInteger() && (*
this) >= 0); }
128 unsigned int getUnsigned()
const;
132 friend std::ostream &
operator<<(std::ostream &os,
const Impl &n);
162 FatalAssert(base != 0 || pow >= 0,
"Attempt to divide by zero");
166 for(; pow > 0; --
pow) res *= base;
176 num = intRoot(num, n);
179 den = intRoot(den, n);
205 friend class Rational::Impl;
219 Unsigned(
const char* n,
int base = 10);
220 Unsigned(
const std::string& n,
int base = 10);
227 std::string toString(
int base = 10)
const;
262 unsigned long getUnsigned()
const;
287 for(; pow > (unsigned)0; --
pow) res *= base;
const Unsigned & operator++()
Prefix increment.
Unsigned operator++(int)
Postfix increment.
Rational getNumerator() const
Description: Collection of debugging macros and functions.
Rational operator++(int)
Postfix increment.
bool operator<=(const Expr &e1, const Expr &e2)
ostream & operator<<(ostream &os, const Expr &e)
void printUnsigned(const Unsigned &x)
Expr operator+(const Expr &left, const Expr &right)
Expr operator/(const Expr &left, const Expr &right)
std::string toString(int base=10) const
#define DebugAssert(cond, str)
bool operator==(const Expr &e1, const Expr &e2)
bool operator>(const Expr &e1, const Expr &e2)
Expr operator-(const Expr &child)
Unsigned newUnsigned(int n)
void printRational(const Rational &x)
Rational operator--(int)
Postfix decrement.
Expr operator*(const Expr &left, const Expr &right)
#define FatalAssert(cond, msg)
If something goes horribly wrong, print a message and abort immediately with exit(1).
const Unsigned & operator--()
Prefix decrement.
Rational getDenominator() const
const Rational & operator++()
Prefix increment.
bool operator<(const Expr &e1, const Expr &e2)
bool operator>=(const Expr &e1, const Expr &e2)
const Rational & operator--()
Prefix decrement.
Unsigned operator--(int)
Postfix decrement.
bool operator!=(const Expr &e1, const Expr &e2)
Rational pow(Rational pow, const Rational &base)
Raise 'base' into the power of 'pow' (pow must be an integer)
Rational newRational(int n, int d=1)
Rational ratRoot(const Rational &base, unsigned long int n)
take nth root of base, return result if it is exact, 0 otherwise