7 #if !defined(CNL_IMPL_SCALED_DEFINITION_H)
8 #define CNL_IMPL_SCALED_DEFINITION_H
10 #include "declaration.h"
24 template<
int Exponent,
int Radix>
26 static_assert(Radix >= 2,
"Radix must be two or greater");
35 constexpr
static int radix = Radix;
45 template<
int LhsExponent,
int RhsExponent,
int Radix>
52 template<
int LhsExponent,
int RhsExponent,
int Radix>
53 [[nodiscard]] constexpr
auto operator-(power<LhsExponent, Radix>, power<RhsExponent, Radix>)
54 -> power<
std::min(LhsExponent, RhsExponent), Radix>
56 return power<
std::min(LhsExponent, RhsExponent), Radix>{};
59 template<
int LhsExponent,
int RhsExponent,
int Radix>
60 [[nodiscard]] constexpr
auto operator*(power<LhsExponent, Radix>, power<RhsExponent, Radix>)
61 -> power<LhsExponent + RhsExponent, Radix>
63 return power<LhsExponent + RhsExponent, Radix>{};
66 template<
int LhsExponent,
int RhsExponent,
int Radix>
67 [[nodiscard]] constexpr
auto operator/(power<LhsExponent, Radix>, power<RhsExponent, Radix>)
68 -> power<LhsExponent - RhsExponent, Radix>
70 return power<LhsExponent - RhsExponent, Radix>{};
73 template<
int LhsExponent,
int RhsExponent,
int Radix>
74 [[nodiscard]] constexpr
auto operator%(power<LhsExponent, Radix>, power<RhsExponent, Radix>)
75 -> power<LhsExponent, Radix>
77 return power<LhsExponent, Radix>{};
80 template<
int LhsExponent,
int RhsExponent,
int Radix>
81 [[nodiscard]] constexpr
auto operator&(power<LhsExponent, Radix>, power<RhsExponent, Radix>)
82 -> power<
std::min(LhsExponent, RhsExponent), Radix>
84 return power<
std::min(LhsExponent, RhsExponent), Radix>{};
87 template<
int LhsExponent,
int RhsExponent,
int Radix>
88 [[nodiscard]] constexpr
auto operator|(power<LhsExponent, Radix>, power<RhsExponent, Radix>)
89 -> power<
std::min(LhsExponent, RhsExponent), Radix>
91 return power<
std::min(LhsExponent, RhsExponent), Radix>{};
94 template<
int LhsExponent,
int RhsExponent,
int Radix>
95 [[nodiscard]] constexpr
auto operator^(power<LhsExponent, Radix>, power<RhsExponent, Radix>)
96 -> power<
std::min(LhsExponent, RhsExponent), Radix>
98 return power<
std::min(LhsExponent, RhsExponent), Radix>{};
102 #endif // CNL_IMPL_SCALED_DEFINITION_H