|
NTLib - Number Theory Library 0.9
|
Represents a rational number. More...
Public Member Functions | |
| rational (T n, T d=1) noexcept | |
| Construct rational from a numerator and a denominator. | |
| T | get_numerator () const noexcept |
| Returns the numerator. | |
| T | get_denominator () const noexcept |
| Returns the denominator. | |
| rational & | operator+= (const rational &rhs) noexcept |
| Compound assignment addition operator. | |
| rational & | operator-= (const rational &rhs) noexcept |
| Compound assignment subtraction operator. | |
| rational & | operator*= (const rational &rhs) noexcept |
| Compound assignment multiplication operator. | |
| rational & | operator/= (const rational &rhs) noexcept |
| Compound assignment division operator. | |
| operator bool () const noexcept | |
| Cast to bool. | |
Friends | |
| rational | operator+ (rational lhs, const rational &rhs) noexcept |
| Addition operator. | |
| rational | operator- (rational lhs, const rational &rhs) noexcept |
| Subtraction operator. | |
| rational | operator* (rational lhs, const rational &rhs) noexcept |
| Multiplication operator. | |
| rational | operator/ (rational lhs, const rational &rhs) noexcept |
| Division operator. | |
Represents a rational number.
| T | An integer-like type. |
|
inlinenoexcept |
Construct rational from a numerator and a denominator.
This constructor allows implicit conversion from elements of type T.
| n | The numerator. |
| d | The denominator. Defaults to 1. |
|
inlinenodiscardnoexcept |
Returns the denominator.
|
inlinenodiscardnoexcept |
Returns the numerator.
|
inlineexplicitnodiscardnoexcept |
Cast to bool.
|
inlinenoexcept |
Compound assignment multiplication operator.
| rhs | The second factor. |
|
inlinenoexcept |
Compound assignment addition operator.
| rhs | The second summand. |
|
inlinenoexcept |
Compound assignment subtraction operator.
| rhs | The subtrahend. |
|
inlinenoexcept |
Compound assignment division operator.
| rhs | The divisor. |
Multiplication operator.
| lhs | The first factor. |
| rhs | The second factor. |
Addition operator.
| lhs | The first summand. |
| rhs | The second summand. |
Subtraction operator.
| lhs | The minuend. |
| rhs | The subtrahend. |
Division operator.
| lhs | The dividend. |
| rhs | The divisor. |