units
Use physical dimensions at compile-time or run-time.
|
Numerator and denominator of a rational number as separate numbers, not encoded into the same word. More...
#include <normalized-pair.hpp>
Public Member Functions | |
constexpr | normalized_pair (S nn, S dd) |
Initialize normalized numerator and denominator for encoding of rational number. More... | |
constexpr S | n () const |
Normalized numerator. More... | |
constexpr U | d () const |
Normalized denominator. More... | |
Private Types | |
using | types = int_types< NMR_BITS+DNM_BITS > |
Working integer-types. More... | |
using | S = typename types::SF |
Fastest large-enough signed type. More... | |
using | U = typename types::UF |
Fastest large-enough unsigned type. More... | |
Static Private Member Functions | |
static constexpr std::pair< S, U > | pair (S n, S d) |
Normalize numerator and denominator. More... | |
Private Attributes | |
std::pair< S, U > | pair_ |
Normalized numerator and denominator. More... | |
Numerator and denominator of a rational number as separate numbers, not encoded into the same word.
These separate numbers are guaranteed to be normalized so that they can be encoded into a word of type rational_base<NMR_BITS, DNM_BITS>::US.
NMR_BITS | Number of bits for numerator. |
DNM_BITS | Number of bits for denominator. |
Definition at line 25 of file normalized-pair.hpp.
|
private |
Fastest large-enough signed type.
Definition at line 31 of file normalized-pair.hpp.
|
private |
Working integer-types.
Definition at line 30 of file normalized-pair.hpp.
|
private |
Fastest large-enough unsigned type.
Definition at line 32 of file normalized-pair.hpp.
|
inline |
Initialize normalized numerator and denominator for encoding of rational number.
Normalization includes making sure that the denominator is positive, that the numerator and denominator are relatively prime, and that each fits in its allocation of bits within the word.
nn | Initial numerator. |
dd | Initial denominator. |
Definition at line 56 of file normalized-pair.hpp.
|
inline |
Normalized denominator.
Definition at line 68 of file normalized-pair.hpp.
|
inline |
Normalized numerator.
Definition at line 67 of file normalized-pair.hpp.
|
inlinestaticprivate |
Normalize numerator and denominator.
n | Input numerator. |
d | Input denominator. |
Definition at line 40 of file normalized-pair.hpp.
|
private |
Normalized numerator and denominator.
Definition at line 34 of file normalized-pair.hpp.