Rational: A rational number based on an arbitrary precision integer
|
|
class Rational : public Moveable<Rational>
A rational number based on an arbitrary precision integer type based on intInf.
Arbitrary precision means that the type is never out of bounds.
A rational number means that it is a fraction of a numerator and denominator.
The goal of this focus is to allow to handle almost infinite precision lossless floating numbers
This feature comes with a huge performance penalty.
Rational()
Class default constructor.
Rational(const Rational& v)
Copy constructor based on v..
template <typename T> Rational(T v)
Constructor based in v..
template <typename T> Rational(T n, T d)
Constructor based in numerator n and denominator d..
Rational(double n, double d)
Constructor based on double numerator n and denominator d.
Rational operator-() const
MInus sign.
bool operator<(const Rational& right) const
Logical lower than Rational right operator.
template <typename T> bool operator<(const T& right) const
Logical lower than right operator.
bool operator>(const Rational& right) const
Logical upper than right operator.
template <typename T> bool operator>(const T& right) const
Logical upper than right operator.
template <typename T> const Rational& operator=(T v)
Assignment operator from v.
const Rational& operator=(double d)
Assignment operator from d.
void operator++()
Operator increment
void operator--()
Operator decrement
void operator+=(const Rational& right)
Operator increment with right.
void operator-=(const Rational& right)
Operator decrement with right.
void operator*=(const Rational& right)
Operator multiply by right.
void operator/=(const Rational& right)
Operator divide between right.
bool operator==(Rational& right) const
Logical operator equal to right.
template <typename T> bool operator==(T right) const
Logical operator equal to right.
bool operator!=(Rational& right) const
Logical operator different to right .
template <typename T> bool operator!=(T right) const
Logical operator different to right .
template <typename T> operator T()
Operator cast.
operator double()
Operator cast to double
Rational Simplify(bool full = false)
Simplify fraction. If full is set, it simplifies using all possible values.
This operation may be very slow
String ToString() const
Conversion to String.
Rational abs(const Rational &v)
Gets absolute value of v
Rational pow(const Rational &v, int e)
Gets rational v raised to integer e.
Rational sqrt(const Rational &v)
Approximate square root v.
String FormatRational(const Rational &d, int numDec)
Gets an String of rational d. numDec .indicates the floating point number of decimals. If numDec is Null, String is shown as a fraction.
|