7 #if !defined(CNL_IMPL_DUPLEX_INTEGER_MODULO_H)
8 #define CNL_IMPL_DUPLEX_INTEGER_MODULO_H
10 #include "../../wide_integer.h"
11 #include "../custom_operator/definition.h"
12 #include "../custom_operator/op.h"
13 #include "definition.h"
22 template<
typename Lhs,
typename Rhs>
23 struct heterogeneous_duplex_modulo_operator {
25 std::max(digits_v<Lhs>, digits_v<Rhs>),
26 numbers::set_signedness_t<int, numbers::signedness_v<Lhs> | numbers::signedness_v<Rhs>>>>;
28 [[nodiscard]] constexpr
auto operator()(Lhs
const& lhs, Rhs
const& rhs)
const -> Lhs
30 return static_cast<Lhs
>(
31 static_cast<common_type
>(lhs) /
static_cast<common_type
>(rhs));
37 template<
typename Upper,
typename Lower>
38 struct custom_operator<
40 op_value<_impl::duplex_integer<Upper, Lower>>,
41 op_value<_impl::duplex_integer<Upper, Lower>>> {
43 using duplex_integer = _impl::duplex_integer<Upper, Lower>;
46 [[nodiscard]] constexpr
auto operator()(
47 duplex_integer
const& lhs, duplex_integer
const& rhs)
const -> duplex_integer
49 return lhs - rhs * (lhs / rhs);
53 template<
typename LhsUpper,
typename LhsLower,
typename RhsUpper,
typename RhsLower>
54 struct custom_operator<
56 op_value<_impl::duplex_integer<LhsUpper, LhsLower>>,
57 op_value<_impl::duplex_integer<RhsUpper, RhsLower>>>
58 : _impl::heterogeneous_duplex_modulo_operator<
59 _impl::duplex_integer<LhsUpper, LhsLower>,
60 _impl::duplex_integer<RhsUpper, RhsLower>> {
63 template<
typename Lhs,
typename RhsUpper,
typename RhsLower>
64 struct custom_operator<
67 op_value<_impl::duplex_integer<RhsUpper, RhsLower>>>
68 : _impl::heterogeneous_duplex_modulo_operator<
69 Lhs, _impl::duplex_integer<RhsUpper, RhsLower>> {
72 template<
typename LhsUpper,
typename LhsLower,
typename Rhs>
73 struct custom_operator<
75 op_value<_impl::duplex_integer<LhsUpper, LhsLower>>,
77 : _impl::heterogeneous_duplex_modulo_operator<
78 _impl::duplex_integer<LhsUpper, LhsLower>, Rhs> {
82 #endif // CNL_IMPL_DUPLEX_INTEGER_MODULO_H