di 0.1.0
Loading...
Searching...
No Matches
di::math::Rational< T > Class Template Reference

#include <di/math/rational/rational.h>

Public Member Functions

constexpr Rational ()
constexpr Rational (T numerator, T denominator=1)
template<concepts::SignedInteger U>
requires (concepts::ConstructibleFrom<T, U>)
constexpr explicit (sizeof(U)<=sizeof(T)) operator Rational< U >() const
constexpr auto numerator () const -> T
constexpr auto denominator () const -> T
constexpr auto negative () const -> bool
constexpr auto add (Rational other) const -> Rational
constexpr auto multiply (Rational other) const -> Rational
constexpr auto subtract (Rational other) const -> Rational
constexpr auto divide (Rational other) const -> Rational
constexpr auto negated () const -> Rational
constexpr auto inverted () const -> Rational
constexpr auto round () const -> T
constexpr auto operator++ () -> Rational &
constexpr auto operator++ (int) -> Rational
constexpr auto operator-- () -> Rational &
constexpr auto operator-- (int) -> Rational
constexpr auto operator+= (Rational a) -> Rational &
constexpr auto operator+ (Rational a) const -> Rational
constexpr auto operator-= (Rational a) -> Rational &
constexpr auto operator- (Rational a) const -> Rational
constexpr auto operator*= (Rational a) -> Rational &
constexpr auto operator* (Rational a) const -> Rational
constexpr auto operator/= (Rational a) -> Rational &
constexpr auto operator/ (Rational a) const -> Rational
constexpr auto operator- () const -> Rational

Public Attributes

m_numerator
m_denominator

Friends

constexpr friend auto operator== (Rational, Rational) -> bool=default
constexpr friend auto operator<=> (Rational a, Rational b) -> strong_ordering

Constructor & Destructor Documentation

◆ Rational() [1/2]

template<concepts::SignedInteger T>
di::math::Rational< T >::Rational ( )
inlineconstexpr

◆ Rational() [2/2]

template<concepts::SignedInteger T>
di::math::Rational< T >::Rational ( T numerator,
T denominator = 1 )
inlineconstexpr

Member Function Documentation

◆ add()

template<concepts::SignedInteger T>
auto di::math::Rational< T >::add ( Rational< T > other) const->Rational
inlineconstexpr

◆ denominator()

template<concepts::SignedInteger T>
auto di::math::Rational< T >::denominator ( ) const->T
inlineconstexpr

◆ divide()

template<concepts::SignedInteger T>
auto di::math::Rational< T >::divide ( Rational< T > other) const->Rational
inlineconstexpr

◆ explicit()

template<concepts::SignedInteger T>
template<concepts::SignedInteger U>
requires (concepts::ConstructibleFrom<T, U>)
di::math::Rational< T >::explicit ( sizeof(U)<=sizeof(T) ) const
inlineconstexpr

◆ inverted()

template<concepts::SignedInteger T>
auto di::math::Rational< T >::inverted ( ) const->Rational
inlineconstexpr

◆ multiply()

template<concepts::SignedInteger T>
auto di::math::Rational< T >::multiply ( Rational< T > other) const->Rational
inlineconstexpr

◆ negated()

template<concepts::SignedInteger T>
auto di::math::Rational< T >::negated ( ) const->Rational
inlineconstexpr

◆ negative()

template<concepts::SignedInteger T>
auto di::math::Rational< T >::negative ( ) const->bool
inlineconstexpr

◆ numerator()

template<concepts::SignedInteger T>
auto di::math::Rational< T >::numerator ( ) const->T
inlineconstexpr

◆ operator*()

template<concepts::SignedInteger T>
auto di::math::Rational< T >::operator* ( Rational< T > a) const->Rational
inlineconstexpr

◆ operator*=()

template<concepts::SignedInteger T>
auto di::math::Rational< T >::operator*= ( Rational< T > a) ->Rational &
inlineconstexpr

◆ operator+()

template<concepts::SignedInteger T>
auto di::math::Rational< T >::operator+ ( Rational< T > a) const->Rational
inlineconstexpr

◆ operator++() [1/2]

template<concepts::SignedInteger T>
auto di::math::Rational< T >::operator++ ( ) ->Rational &
inlineconstexpr

◆ operator++() [2/2]

template<concepts::SignedInteger T>
auto di::math::Rational< T >::operator++ ( int ) ->Rational
inlineconstexpr

◆ operator+=()

template<concepts::SignedInteger T>
auto di::math::Rational< T >::operator+= ( Rational< T > a) ->Rational &
inlineconstexpr

◆ operator-() [1/2]

template<concepts::SignedInteger T>
auto di::math::Rational< T >::operator- ( ) const->Rational
inlineconstexpr

◆ operator-() [2/2]

template<concepts::SignedInteger T>
auto di::math::Rational< T >::operator- ( Rational< T > a) const->Rational
inlineconstexpr

◆ operator--() [1/2]

template<concepts::SignedInteger T>
auto di::math::Rational< T >::operator-- ( ) ->Rational &
inlineconstexpr

◆ operator--() [2/2]

template<concepts::SignedInteger T>
auto di::math::Rational< T >::operator-- ( int ) ->Rational
inlineconstexpr

◆ operator-=()

template<concepts::SignedInteger T>
auto di::math::Rational< T >::operator-= ( Rational< T > a) ->Rational &
inlineconstexpr

◆ operator/()

template<concepts::SignedInteger T>
auto di::math::Rational< T >::operator/ ( Rational< T > a) const->Rational
inlineconstexpr

◆ operator/=()

template<concepts::SignedInteger T>
auto di::math::Rational< T >::operator/= ( Rational< T > a) ->Rational &
inlineconstexpr

◆ round()

template<concepts::SignedInteger T>
auto di::math::Rational< T >::round ( ) const->T
inlineconstexpr

◆ subtract()

template<concepts::SignedInteger T>
auto di::math::Rational< T >::subtract ( Rational< T > other) const->Rational
inlineconstexpr

◆ operator<=>

template<concepts::SignedInteger T>
friend auto operator<=> ( Rational< T > a,
Rational< T > b )->strong_ordering
friend

◆ operator==

template<concepts::SignedInteger T>
friend auto operator== ( Rational< T > ,
Rational< T >  )->bool=default
friend

Member Data Documentation

◆ m_denominator

template<concepts::SignedInteger T>
T di::math::Rational< T >::m_denominator

◆ m_numerator

template<concepts::SignedInteger T>
T di::math::Rational< T >::m_numerator

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