10 #if !defined(CNL_IMPL_SCALED_INTEGER_NAMED_H)
11 #define CNL_IMPL_SCALED_INTEGER_NAMED_H
13 #include "../num_traits/rep_of.h"
14 #include "../num_traits/tag_of.h"
15 #include "../scaled/power.h"
32 template<
typename Value>
35 return _impl::from_value<scaled_integer<>, Value>(value);
38 template<fixed_po
int Numerator, fixed_po
int Denominator>
41 template<
class Div
idend,
class Divisor>
44 using natural_result = _impl::op_result<_impl::divide_op, Dividend, Divisor>;
46 constexpr
int integer_digits = _impl::integer_digits<Dividend> + _impl::fractional_digits<Divisor>;
47 constexpr
int fractional_digits = _impl::fractional_digits<Dividend> + _impl::integer_digits<Divisor>;
49 constexpr
auto necessary_digits = integer_digits + fractional_digits;
50 constexpr
auto natural_digits = digits_v<natural_result>;
51 constexpr
auto result_digits =
std::max(necessary_digits, natural_digits);
53 constexpr
int rep_exponent = -fractional_digits;
54 using scale = power<rep_exponent>;
56 using rep_type = set_digits_t<natural_result, result_digits>;
57 using rep = decltype(_impl::not_scaled_integer(std::declval<rep_type>()));
59 return _impl::from_rep<scaled_integer<rep, scale>>(
60 convert<scale, rep, power<>>{}(f));
75 template<
class Div
idend,
class Divisor>
76 [[nodiscard]] constexpr
auto quotient(Dividend
const& dividend, Divisor
const& divisor)
82 #endif // CNL_IMPL_SCALED_INTEGER_NAMED_H