7 #if !defined(CNL_IMPL_NUM_TRAITS_SCALE_H)
8 #define CNL_IMPL_NUM_TRAITS_SCALE_H
10 #include "../../integer.h"
11 #include "../power_value.h"
14 template<
int Digits,
int Radix,
class S>
19 template<
int Digits,
int Radix,
typename S>
22 template<
int Digits,
int Radix,
typename S>
23 requires(0 <= Digits)
struct default_scale<Digits, Radix, S> {
24 [[nodiscard]] constexpr
auto operator()(S
const& s)
const
26 return s * power_value<S, Digits, Radix>();
31 template<
int Digits,
int Radix,
typename S>
32 requires(Digits < 0) struct default_scale<Digits, Radix, S> {
33 [[nodiscard]] constexpr
auto operator()(S
const& s)
const
35 return s / power_value<S, -Digits, Radix>();
41 template<
int Digits,
int Radix,
integer S>
42 struct scale<Digits, Radix, S>
43 : _impl::default_scale<Digits, Radix, S> {
48 template<
int Digits,
int Radix = 2,
class S>
49 [[nodiscard]] constexpr
auto scale(S
const& s)
51 return cnl::scale<Digits, Radix, S>{}(s);
56 #endif // CNL_IMPL_NUM_TRAITS_SCALE_H