10 #if !defined(CNL_ELASTIC_SCALED_INTEGER_H)
11 #define CNL_ELASTIC_SCALED_INTEGER_H
13 #include "_impl/charconv/descale.h"
14 #include "_impl/numbers/adopt_signedness.h"
15 #include "_impl/scaled/is_scaled_tag.h"
16 #include "_impl/scaled/power.h"
22 #include <type_traits>
39 template<
int Digits, scaled_tag Scale = power<>,
class Narrowest =
signed>
64 template<
typename Narrowest =
int, CNL_IMPL_CONSTANT_VALUE_TYPE Value = 0>
68 power<trailing_bits(Value)>, Narrowest>
92 template<
typename Narrowest =
void,
typename Integral =
int>
98 _impl::adopt_signedness_t<int, Integral>, Narrowest>::type>
103 template<
typename Narrowest =
void,
typename Rep =
int, scaled_tag Scale = power<>>
109 _impl::adopt_signedness_t<int, Rep>, Narrowest>::type>
115 template<
integer auto ParsedSignificand,
integer auto ParsedExponent,
int ParsedRadix,
int UdlRadix>
116 [[nodiscard]] constexpr
auto make_from_udl()
118 constexpr
auto descaled{
119 descale<decltype(ParsedSignificand), UdlRadix, true>(
121 power<ParsedExponent, ParsedRadix>{})};
122 constexpr
auto rep{make_elastic_integer(constant<descaled.significand>{})};
125 power<descaled.exponent, descaled.radix>>>(rep);
149 template<
char... Chars>
150 [[nodiscard]] constexpr
auto operator"" _cnl()
152 constexpr
auto parsed{_impl::parse_real<intmax_t, Chars...>()};
153 return _impl::make_from_udl<parsed.significand, parsed.exponent, parsed.radix, parsed.radix>();
167 template<
char... Chars>
168 [[nodiscard]] constexpr
auto operator"" _cnl2()
170 constexpr
auto parsed{_impl::parse_real<intmax_t, Chars...>()};
171 return _impl::make_from_udl<parsed.significand, parsed.exponent, parsed.radix, 2>();
176 #endif // CNL_ELASTIC_SCALED_INTEGER_H