Fixed size rational number \( \frac{a}{b} \) using std::int64_t for numerator and denominator.
More...
#include <Rational.h>
|
std::int64_t | a |
| Numerator.
|
|
std::int64_t | b |
| Denominator.
|
|
Fixed size rational number \( \frac{a}{b} \) using std::int64_t for numerator and denominator.
◆ Rational() [1/2]
template<std::integral Integer>
pbat::math::Rational::Rational |
( |
Integer | _a, |
|
|
Integer | _b ) |
|
inline |
Construct a new Rational object.
- Template Parameters
-
- Parameters
-
◆ Rational() [2/2]
template<std::integral Integer>
pbat::math::Rational::Rational |
( |
Integer | value | ) |
|
|
inline |
Construct a new Rational object.
- Template Parameters
-
- Parameters
-
- Postcondition
- Denominator is set to 1
◆ operator double()
pbat::math::Rational::operator double |
( |
| ) |
const |
|
explicit |
◆ operator float()
pbat::math::Rational::operator float |
( |
| ) |
const |
|
explicit |
◆ operator*()
Multiplication operation.
- Parameters
-
other | Right-hand side operand |
- Returns
- Result of multiplication
◆ operator+()
Addition operation.
- Parameters
-
other | Right-hand side operand |
- Returns
- Result of addition
◆ operator-() [1/2]
Rational pbat::math::Rational::operator- |
( |
| ) |
const |
Negation operation.
- Returns
- Result of negation
◆ operator-() [2/2]
Subtraction operation.
- Parameters
-
other | Right-hand side operand |
- Returns
- Result of subtraction
◆ operator/()
Division operation.
- Parameters
-
other | Right-hand side operand |
- Returns
- Result of division
◆ operator<()
bool pbat::math::Rational::operator< |
( |
Rational const & | other | ) |
const |
Less-than operation.
- Parameters
-
other | Right-hand side operand |
- Returns
- true if not equal
◆ operator==()
bool pbat::math::Rational::operator== |
( |
Rational const & | other | ) |
const |
Equality operation.
- Parameters
-
other | Right-hand side operand |
- Returns
- true if equal
◆ Rebase()
bool pbat::math::Rational::Rebase |
( |
std::int64_t | denominator | ) |
|
Change internal rational representation to have denominator denominator.
- Parameters
-
denominator | New denominator |
- Returns
- true if successful
The documentation for this struct was generated from the following files:
- C:/git/PhysicsBasedAnimationToolkit/source/pbat/math/Rational.h
- C:/git/PhysicsBasedAnimationToolkit/source/pbat/math/Rational.cpp