CNL
2.0.2 (development)
Compositional Numeric Library
|
7 #if !defined(CNL_IMPL_FRACTION_DEFINITION_H)
8 #define CNL_IMPL_FRACTION_DEFINITION_H
10 #include "../../fixed_point.h"
11 #include "../../integer.h"
12 #include "../num_traits/set_width.h"
13 #include "../ssizeof.h"
17 #include <type_traits>
27 template<fixed_po
int Numerator =
int, fixed_po
int Denominator = Numerator>
31 "ill-formed if only one template parameter is floating-point");
39 explicit constexpr
fraction(Numerator n, Denominator d);
41 template<
integer Integer>
42 explicit constexpr
fraction(Integer
const& i);
44 template<fixed_po
int RhsNumerator, fixed_po
int RhsDenominator>
48 template<std::
floating_po
int FloatingPo
int>
49 explicit constexpr
fraction(FloatingPoint);
52 template<std::
floating_po
int Scalar>
53 [[nodiscard]]
explicit constexpr
operator Scalar()
const
65 fraction(
float)->fraction<_impl::set_width_t<int, _impl::ssizeof<float>() * CHAR_BIT>>;
67 fraction(
double)->fraction<_impl::set_width_t<int, _impl::ssizeof<double>() * CHAR_BIT>>;
69 #if defined(CNL_INT128_ENABLED)
70 fraction(
long double)->fraction<_impl::set_width_t<int, _impl::ssizeof<long double>() * CHAR_BIT>>;
73 template<
integer Integer>
77 #endif // CNL_IMPL_FRACTION_DEFINITION_H
numeric type represented as the fraction, numerator / denominator
Definition: definition.h:28
denominator_type denominator
the denominator (bottom number) of the fraction
Definition: definition.h:62
Numerator numerator_type
alias to Numerator
Definition: definition.h:34
numerator_type numerator
the numerator (top number) of the fraction
Definition: definition.h:59
compositional numeric library
Definition: abort.h:15
Denominator denominator_type
alias to Denominator
Definition: definition.h:37