Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site











SourceForge.net Logo

Rational

 

class Rational : public Moveable<Rational

 

An arbitrary integer precision rational number 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.

 

Constructor Detail


 

Rational()

Class default constructor.

 


 

Rational(const Rational& v)

Copy constructor based on v..

 


 

template <typename TRational(T v)

Constructor based in v..

 


 

template <typename TRational(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.

 

Public Member List


 

Rational operator-() const

MInus sign.

 


 

bool operator<(const Rational& rightconst

Logical lower than Rational right operator.

 


 

template <typename Tbool operator<(const T& rightconst

Logical lower than right operator.

 


 

bool operator>(const Rational& rightconst

Logical upper than  right operator.

 


 

template <typename Tbool operator>(const T& rightconst

Logical upper than right operator.

 


 

template <typename Tconst 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& rightconst

Logical operator equal to right.

 


 

template <typename Tbool operator==(T rightconst

Logical operator equal to  right.

 


 

bool operator!=(Rational& rightconst

Logical operator different to  right .

 


 

template <typename Tbool operator!=(T rightconst

Logical operator different to  right .

 


 

template <typename Toperator 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.

 

Public Member List


 

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.

 

 

Last edit by koldo on 02/25/2020. Do you want to contribute?. T++