Shaka Player Embedded
Public Member Functions | Public Attributes | List of all members
shaka::Rational< T > Struct Template Referencefinal

#include <utils.h>

Public Member Functions

 Rational ()=default
 
 Rational (T num, T den)
 
truncate () const
 
Rational< T > inverse () const
 
 operator bool () const
 
 operator double () const
 
template<typename U >
bool operator== (const Rational< U > &other) const
 
template<typename U >
bool operator!= (const Rational< U > &other) const
 
template<typename U >
Rational< common< U > > operator* (const Rational< U > &other) const
 
template<typename U , typename = enable_if_num<U>>
Rational< common< U > > operator* (U other) const
 
template<typename U >
Rational< common< U > > operator/ (const Rational< U > &other) const
 
template<typename U , typename = enable_if_num<U>>
Rational< common< U > > operator/ (U other) const
 

Public Attributes

numerator
 
denominator
 

Detailed Description

template<typename T>
struct shaka::Rational< T >

Defines a rational number (i.e. a fraction) in a way to reduce the number of rounding errors. Using the constructor or operators results in a reduced fraction, to reduce the chances of overflow. Since this uses a fixed-sized integer, this can still cause overflow with large numbers.

Definition at line 95 of file utils.h.

Constructor & Destructor Documentation

§ Rational() [1/2]

template<typename T>
shaka::Rational< T >::Rational ( )
default

§ Rational() [2/2]

template<typename T>
shaka::Rational< T >::Rational ( num,
den 
)
inline

Definition at line 151 of file utils.h.

Member Function Documentation

§ inverse()

template<typename T>
Rational<T> shaka::Rational< T >::inverse ( ) const
inline

Definition at line 156 of file utils.h.

§ operator bool()

template<typename T>
shaka::Rational< T >::operator bool ( ) const
inline

Definition at line 160 of file utils.h.

§ operator double()

template<typename T>
shaka::Rational< T >::operator double ( ) const
inline

Definition at line 163 of file utils.h.

§ operator!=()

template<typename T>
template<typename U >
bool shaka::Rational< T >::operator!= ( const Rational< U > &  other) const
inline

Definition at line 173 of file utils.h.

§ operator*() [1/2]

template<typename T>
template<typename U >
Rational<common<U> > shaka::Rational< T >::operator* ( const Rational< U > &  other) const
inline

Definition at line 178 of file utils.h.

§ operator*() [2/2]

template<typename T>
template<typename U , typename = enable_if_num<U>>
Rational<common<U> > shaka::Rational< T >::operator* ( other) const
inline

Definition at line 183 of file utils.h.

§ operator/() [1/2]

template<typename T>
template<typename U >
Rational<common<U> > shaka::Rational< T >::operator/ ( const Rational< U > &  other) const
inline

Definition at line 188 of file utils.h.

§ operator/() [2/2]

template<typename T>
template<typename U , typename = enable_if_num<U>>
Rational<common<U> > shaka::Rational< T >::operator/ ( other) const
inline

Definition at line 193 of file utils.h.

§ operator==()

template<typename T>
template<typename U >
bool shaka::Rational< T >::operator== ( const Rational< U > &  other) const
inline

Definition at line 168 of file utils.h.

§ truncate()

template<typename T>
T shaka::Rational< T >::truncate ( ) const
inline

Definition at line 153 of file utils.h.

Member Data Documentation

§ denominator

template<typename T>
T shaka::Rational< T >::denominator

Definition at line 198 of file utils.h.

§ numerator

template<typename T>
T shaka::Rational< T >::numerator

Definition at line 197 of file utils.h.


The documentation for this struct was generated from the following file: