Monado OpenXR Runtime
|
A rational (fractional) number type. More...
#include <math/m_rational.hpp>
Public Types | |
using | value_type = Scalar |
Public Member Functions | |
constexpr Rational | reciprocal () const noexcept |
Return the reciprocal of this value. More... | |
constexpr Rational | withNonNegativeDenominator () const noexcept |
Return this value, with the denominator non-negative (0 or positive). More... | |
constexpr bool | isOverUnity () const noexcept |
Does this rational number represent a value greater than 1, with a positive denominator? More... | |
constexpr bool | isUnity () const noexcept |
Does this rational number represent 1? More... | |
constexpr bool | isZero () const noexcept |
Does this rational number represent 0? More... | |
constexpr bool | isBetweenZeroAndOne () const noexcept |
Does this rational number represent a value between 0 and 1 (exclusive), and has a positive denominator? More... | |
constexpr Rational | complement () const noexcept |
Get the complementary fraction. More... | |
constexpr float | as_float () const noexcept |
Get an approximation of this value as a float. More... | |
constexpr double | as_double () const noexcept |
Get an approximation of this value as a double. More... | |
Static Public Member Functions | |
static constexpr Rational< Scalar > | simplestUnity () noexcept |
Return the rational value 1/1, the simplest unity (== 1) value. More... | |
Data Fields | |
value_type | numerator |
value_type | denominator |
Related Functions | |
(Note that these are not member functions.) | |
template<typename Scalar > | |
constexpr Rational< Scalar > | operator* (const Rational< Scalar > &lhs, const Rational< Scalar > &rhs) |
Multiplication operator. More... | |
template<typename Scalar > | |
constexpr Rational< Scalar > | operator* (const Rational< Scalar > &lhs, const Scalar &rhs) |
Multiplication operator with a scalar. More... | |
template<typename Scalar > | |
constexpr Rational< Scalar > | operator* (const Scalar &lhs, const Rational< Scalar > &rhs) |
Multiplication operator with a scalar. More... | |
template<typename Scalar > | |
constexpr bool | operator== (const Rational< Scalar > &lhs, const Rational< Scalar > &rhs) |
Equality comparison operator. More... | |
template<typename Scalar > | |
constexpr Rational< Scalar > | operator/ (const Rational< Scalar > &lhs, const Rational< Scalar > &rhs) |
Division operator. More... | |
template<typename Scalar > | |
constexpr Rational< Scalar > | operator/ (const Rational< Scalar > &lhs, Scalar rhs) |
Division operator by a scalar. More... | |
A rational (fractional) number type.
|
inlineconstexprnoexcept |
Get an approximation of this value as a double.
|
inlineconstexprnoexcept |
Get an approximation of this value as a float.
|
inlineconstexprnoexcept |
Get the complementary fraction.
Only really makes sense if isBetweenZeroAndOne() is true
Result will have a non-negative denominator.
|
inlineconstexprnoexcept |
Does this rational number represent a value between 0 and 1 (exclusive), and has a positive denominator?
This is the most common useful range.
|
inlineconstexprnoexcept |
Does this rational number represent a value greater than 1, with a positive denominator?
|
inlineconstexprnoexcept |
Does this rational number represent 1?
|
inlineconstexprnoexcept |
Does this rational number represent 0?
|
inlineconstexprnoexcept |
Return the reciprocal of this value.
Result will have a non-negative denominator.
Referenced by xrt::auxiliary::math::Rational< Scalar >::operator/().
|
inlinestaticconstexprnoexcept |
Return the rational value 1/1, the simplest unity (== 1) value.
|
inlineconstexprnoexcept |
Return this value, with the denominator non-negative (0 or positive).
|
related |
Multiplication operator.
Warning: does no simplification!
Result will have a non-negative denominator.
|
related |
Multiplication operator with a scalar.
Warning: does no simplification!
Result will have a non-negative denominator.
|
related |
Multiplication operator with a scalar.
Warning: does no simplification!
Result will have a non-negative denominator.
|
related |
Division operator.
Warning: does no simplification!
Result will have a non-negative denominator.
References xrt::auxiliary::math::Rational< Scalar >::reciprocal().
|
related |
Division operator by a scalar.
Warning: does no simplification!
Result will have a non-negative denominator.
|
related |
Equality comparison operator.
Warning: does no simplification, looks for exact equality!