Primary module interface unit for module rational.
More...
#include <cassert>
#include <compare>
#include <ostream>
#include <string>
#include <type_traits>
import base;
Primary module interface unit for module rational.
◆ operator-()
Unary minus operator.
- Template Parameters
-
- Parameters
-
- Returns
- The rational with the same absolute value but opposite sign.
◆ operator<<()
template<Integer T>
| std::ostream & ntlib::operator<< |
( |
std::ostream & | os, |
|
|
const rational< T > & | r ) |
|
export |
Stream insertion operator.
- Template Parameters
-
- Parameters
-
| os | The output stream. |
| r | The rational. |
- Returns
- The output stream.
◆ operator<=>()
template<Integer T>
| std::strong_ordering ntlib::operator<=> |
( |
const rational< T > & | lhs, |
|
|
const rational< T > & | rhs ) |
|
nodiscardexport |
Three-way comparison operator.
- Template Parameters
-
- Parameters
-
| lhs | The left hand side to compare. |
| rhs | The right hand side to compare. |
- Return values
-
| <0 | If lhs < rhs. |
| 0 | If lhs == rhs. |
| >0 | If lhs > rhs. |
◆ operator==()
Equality operator.
- Parameters
-
| lhs | The left hand side to compare. |
| rhs | The right hand side to compare. |
- Returns
- True, if and only if lhs is equal to rhs.
◆ to_string()
template<Integer T>
| std::string ntlib::to_string |
( |
const rational< T > & | r | ) |
|
|
nodiscardexport |
Creates a string "a/b" where a and b are coprime.
- Template Parameters
-
- Parameters
-
- Returns
- A string representation.