20 std::common_type_t<std::decay_t<decltype(rhs)>, std::decay_t<decltype(lhs)>> { x }
23template <
size_t Bits,
typename Signed>
class numeric_limits<wide_integer<Bits, Signed>> {
25 static constexpr bool is_specialized =
true;
26 static constexpr bool is_signed = is_same<Signed, signed>::value;
27 static constexpr bool is_integer =
true;
28 static constexpr bool is_exact =
true;
29 static constexpr bool has_infinity =
false;
30 static constexpr bool has_quiet_NaN =
false;
31 static constexpr bool has_signaling_NaN =
true;
32 static constexpr std::float_denorm_style has_denorm = std::denorm_absent;
33 static constexpr bool has_denorm_loss =
false;
34 static constexpr std::float_round_style round_style = std::round_toward_zero;
35 static constexpr bool is_iec559 =
false;
36 static constexpr bool is_bounded =
true;
37 static constexpr bool is_modulo =
true;
38 static constexpr int digits = Bits - (is_same<Signed, signed>::value ? 1 : 0);
39 static constexpr int digits10 =
static_cast<int>(digits * 0.30103) ;
40 static constexpr int max_digits10 = 0;
41 static constexpr int radix = 2;
42 static constexpr int min_exponent = 0;
43 static constexpr int min_exponent10 = 0;
44 static constexpr int max_exponent = 0;
45 static constexpr int max_exponent10 = 0;
46 static constexpr bool traps =
true;
47 static constexpr bool tinyness_before =
false;
49 static constexpr wide_integer<Bits, Signed> min() noexcept {
50 if (is_same<Signed, signed>::value) {
51 wide_integer<Bits, signed> res{};
52 res.m_arr[0] = std::numeric_limits<typename wide_integer<Bits, Signed>::signed_base_type>::min();
59 static constexpr wide_integer<Bits, Signed> lowest() noexcept {
return min(); }
61 static constexpr wide_integer<Bits, Signed> max() noexcept {
62 wide_integer<Bits, Signed> res{};
63 res.m_arr[0] = is_same<Signed, signed>::value
64 ? std::numeric_limits<typename wide_integer<Bits, Signed>::signed_base_type>::max()
65 :
std::numeric_limits<typename wide_integer<Bits, Signed>::base_type>::max();
66 for (
int i = 1; i < wide_integer<Bits, Signed>::_impl::arr_size; ++i) {
67 res.m_arr[i] = std::numeric_limits<typename wide_integer<Bits, Signed>::base_type>::max();
72 static constexpr wide_integer<Bits, Signed> epsilon() noexcept {
return 0; }
74 static constexpr wide_integer<Bits, Signed> round_error() noexcept {
return 0; }
76 static constexpr wide_integer<Bits, Signed> infinity() noexcept {
return 0; }
78 static constexpr wide_integer<Bits, Signed> quiet_NaN() noexcept {
return 0; }
80 static constexpr wide_integer<Bits, Signed> signaling_NaN() noexcept {
return 0; }
82 static constexpr wide_integer<Bits, Signed> denorm_min() noexcept {
return 0; }
86template <
class T>
constexpr bool valid_specialized_numeric_limits(std::false_type ) {
87 return std::numeric_limits<T>::is_specialized;
89template <
class T>
constexpr bool valid_specialized_numeric_limits(std::true_type ) {
return false; }
93 return std::detail::valid_specialized_numeric_limits<T>(std::is_array<T>());
97template <
class T>
constexpr bool valid_specialized_numeric_limits_and_integral(std::false_type ) {
98 return std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::is_integer;
100template <
class T>
constexpr bool valid_specialized_numeric_limits_and_integral(std::true_type ) {
105template <
typename T>
static constexpr bool IntegralConcept() noexcept {
106 return std::detail::valid_specialized_numeric_limits_and_integral<T>(std::is_array<T>());
110template <
size_t Bits,
typename Signed,
size_t Bits2,
typename Signed2>
111struct common_type<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>> {
112 using type = std::conditional_t < Bits == Bits2,
114 std::conditional_t<(std::is_same<Signed, Signed2>::value && std::is_same<Signed2, signed>::value),
116 std::conditional_t<Bits2<Bits, wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>>;
119template <
size_t Bits,
typename Signed,
typename Arithmetic>
120struct common_type<wide_integer<Bits, Signed>, Arithmetic> {
121 static_assert(ArithmeticConcept<Arithmetic>(),
"");
123 using type = std::conditional_t<
124 std::is_floating_point<Arithmetic>::value, Arithmetic,
125 std::conditional_t<
sizeof(Arithmetic) < Bits *
sizeof(
long), wide_integer<Bits, Signed>,
126 std::conditional_t<Bits *
sizeof(long) <
sizeof(Arithmetic), Arithmetic,
127 std::conditional_t<Bits *
sizeof(long) ==
sizeof(Arithmetic) &&
128 (is_same<Signed, signed>::value ||
129 std::is_signed<Arithmetic>::value),
130 Arithmetic, wide_integer<Bits, Signed>>>>>;
133template <
typename Arithmetic,
size_t Bits,
typename Signed>
134struct common_type<Arithmetic, wide_integer<Bits, Signed>> : std::common_type<wide_integer<Bits, Signed>, Arithmetic> {
137template <
size_t Bits,
typename Signed>
struct wide_integer<Bits, Signed>::_impl {
138 static_assert(Bits % CHAR_BIT == 0,
"=)");
141 static const int base_bits =
sizeof(
base_type) * CHAR_BIT;
142 static const int arr_size = Bits / base_bits;
144 template <
size_t B>
constexpr static bool is_negative(
const wide_integer<B, signed> &
n)
noexcept {
148 template <
size_t B,
class T>
constexpr static bool is_negative(
const wide_integer<B, T> &)
noexcept {
return false; }
150 template <
size_t B,
class S>
constexpr static wide_integer<B, S> make_positive(
const wide_integer<B, S> &
n)
noexcept {
151 return is_negative(
n) ? operator_unary_minus(
n) :
n;
154 template <typename T, class = typename std::enable_if<std::is_signed<T>::value, T>::type>
155 constexpr static int64_t to_Integral(T f)
noexcept {
156 return static_cast<int64_t
>(f);
158 template <typename T, class = typename std::enable_if<!std::is_signed<T>::value, T>::type>
159 constexpr static uint64_t to_Integral(T f)
noexcept {
160 return static_cast<uint64_t
>(f);
163 template <
typename Integral>
164 constexpr static void wide_integer_from_bultin(wide_integer<Bits, Signed> &self, Integral
rhs)
noexcept {
165 auto r = _impl::to_Integral(
rhs);
169 for (;
static_cast<size_t>(r_idx) <
sizeof(Integral) /
sizeof(
base_type) && r_idx < arr_size; ++r_idx) {
170 base_type &curr = self.m_arr[arr_size - 1 - r_idx];
172 static_cast<base_type>(r >> (r_idx * CHAR_BIT *
sizeof(
base_type))) & std::numeric_limits<base_type>::max();
176 for (; r_idx < arr_size; ++r_idx) {
177 base_type &curr = self.m_arr[arr_size - 1 - r_idx];
178 curr = r < 0 ? std::numeric_limits<base_type>::max() : 0;
182 constexpr static void wide_integer_from_bultin(wide_integer<Bits, Signed> &self,
double rhs)
noexcept {
183 if ((
rhs > 0 &&
rhs < std::numeric_limits<uint64_t>::max()) ||
184 (rhs < 0 && rhs > std::numeric_limits<int64_t>::min())) {
185 self = to_Integral(
rhs);
194 size_t count =
static_cast<size_t>(r / std::numeric_limits<uint64_t>::max());
196 self *= std::numeric_limits<uint64_t>::max();
197 long double to_diff =
count;
198 to_diff *= std::numeric_limits<uint64_t>::max();
200 self += to_Integral(r - to_diff);
207 template <
size_t Bits2,
typename Signed2>
208 constexpr static void wide_integer_from_wide_integer(wide_integer<Bits, Signed> &self,
209 const wide_integer<Bits2, Signed2> &
rhs)
noexcept {
211 auto rhs_arr_size = wide_integer<Bits2, Signed2>::_impl::arr_size;
212 int base_elems_to_copy = _impl::arr_size < rhs_arr_size ? _impl::arr_size : rhs_arr_size;
213 for (
int i = 0; i < base_elems_to_copy; ++i) {
214 self.m_arr[_impl::arr_size - 1 - i] =
rhs.m_arr[rhs_arr_size - 1 - i];
216 for (
int i = 0; i < arr_size - base_elems_to_copy; ++i) {
217 self.m_arr[i] = is_negative(
rhs) ? std::numeric_limits<base_type>::max() : 0;
221 template <
typename T>
222 using __keep_size =
typename std::enable_if<
sizeof(T) * CHAR_BIT <= Bits, wide_integer<Bits, Signed>>::type;
223 template <
size_t Bits2,
typename Signed2>
224 using __need_increase_size =
typename std::enable_if < Bits<Bits2, wide_integer<Bits2, Signed>>::type;
226 template <typename T2, typename = std::enable_if<std::is_integral<T2>::value && std::is_unsigned<T2>::value>>
227 constexpr static wide_integer<Bits, unsigned> shift_left(
const wide_integer<Bits, unsigned> &
rhs, T2
n) {
228 if (
static_cast<size_t>(
n) >= base_bits * arr_size)
233 wide_integer<Bits, Signed> lhs =
rhs;
234 int cur_shift =
n % base_bits;
236 lhs.m_arr[0] =
static_cast<base_type>(lhs.m_arr[0] << cur_shift);
237 for (
int i = 1; i < arr_size; ++i) {
238 lhs.m_arr[i - 1] =
static_cast<base_type>(lhs.m_arr[i - 1] | (lhs.m_arr[i] >> (base_bits - cur_shift)));
239 lhs.m_arr[i] =
static_cast<base_type>(lhs.m_arr[i] << cur_shift);
244 decltype(arr_size -
n / base_bits) i = 0;
245 for (; i < arr_size -
n / base_bits; ++i) {
246 lhs.m_arr[i] = lhs.m_arr[i +
n / base_bits];
248 for (; i < arr_size; ++i) {
255 template <typename T2, typename = std::enable_if<std::is_integral<T2>::value && std::is_unsigned<T2>::value>>
256 constexpr static wide_integer<Bits, signed> shift_left(
const wide_integer<Bits, signed> &
rhs, T2
n) {
259 if (is_negative(
rhs)) {
260 throw std::runtime_error(
"shift left for negative lhsbers is underfined!");
262 return wide_integer<Bits, signed>(shift_left(wide_integer<Bits, unsigned>(
rhs),
n));
265 template <typename T2, typename = std::enable_if<std::is_integral<T2>::value && std::is_unsigned<T2>::value>>
266 constexpr static wide_integer<Bits, unsigned> shift_right(
const wide_integer<Bits, unsigned> &
rhs, T2
n)
noexcept {
267 if (
static_cast<size_t>(
n) >= base_bits * arr_size)
272 wide_integer<Bits, Signed> lhs =
rhs;
273 int cur_shift =
n % base_bits;
275 lhs.m_arr[arr_size - 1] =
static_cast<base_type>(lhs.m_arr[arr_size - 1] >> cur_shift);
276 for (
int i = arr_size - 2; i >= 0; --i) {
277 lhs.m_arr[i + 1] |=
static_cast<base_type>(lhs.m_arr[i + 1] | (lhs.m_arr[i] << (base_bits - cur_shift)));
278 lhs.m_arr[i] =
static_cast<base_type>(lhs.m_arr[i] >> cur_shift);
283 decltype(
n / base_bits) i = arr_size - 1;
284 for (; i >=
n / base_bits; --i) {
285 lhs.m_arr[i] = lhs.m_arr[i -
n / base_bits];
287 for (; i >= 0; --i) {
294 template <typename T2, typename = std::enable_if<std::is_integral<T2>::value && std::is_unsigned<T2>::value>>
295 constexpr static wide_integer<Bits, signed> shift_right(
const wide_integer<Bits, signed> &
rhs, T2
n)
noexcept {
296 if (
static_cast<size_t>(
n) >= base_bits * arr_size)
301 bool is_neg = is_negative(
rhs);
303 return shift_right(wide_integer<Bits, unsigned>(
rhs),
n);
306 wide_integer<Bits, Signed> lhs =
rhs;
307 int cur_shift =
n % base_bits;
309 lhs = shift_right(wide_integer<Bits, unsigned>(lhs), cur_shift);
310 lhs.m_arr[0] |= std::numeric_limits<base_type>::max() << (base_bits - cur_shift);
314 decltype(
n / base_bits) i = arr_size - 1;
315 for (; i >=
n / base_bits; --i) {
316 lhs.m_arr[i] = lhs.m_arr[i -
n / base_bits];
318 for (; i >= 0; --i) {
319 lhs.m_arr[i] = std::numeric_limits<base_type>::max();
325 template <typename T, typename std::enable_if_t<std::is_signed<T>::value,
void *> =
nullptr>
326 constexpr static wide_integer<Bits, Signed> operator_plus_T(
const wide_integer<Bits, Signed> &lhs,
327 T
rhs)
noexcept(is_same<Signed, unsigned>::value) {
329 return _operator_minus_T(lhs, -
rhs);
331 return _operator_plus_T(lhs,
rhs);
335 template <typename T, typename std::enable_if_t<!std::is_signed<T>::value,
void *> =
nullptr>
336 constexpr static wide_integer<Bits, Signed> operator_plus_T(
const wide_integer<Bits, Signed> &lhs,
337 T
rhs)
noexcept(is_same<Signed, unsigned>::value) {
338 return _operator_plus_T(lhs,
rhs);
342 template <
typename T>
343 constexpr static wide_integer<Bits, Signed> _operator_minus_T(
const wide_integer<Bits, Signed> &lhs,
344 T
rhs)
noexcept(is_same<Signed, unsigned>::value) {
345 wide_integer<Bits, Signed> res = lhs;
347 bool is_underflow =
false;
349 for (;
static_cast<size_t>(r_idx) <
sizeof(T) && r_idx < arr_size; ++r_idx) {
350 base_type &res_i = res.m_arr[arr_size - 1 - r_idx];
351 base_type curr_rhs =
static_cast<base_type>(
rhs >> (r_idx * CHAR_BIT)) & std::numeric_limits<base_type>::max();
355 is_underflow = res_i == std::numeric_limits<base_type>::max();
358 if (res_i < curr_rhs) {
361 res_i =
static_cast<base_type>(res_i - curr_rhs);
364 if (is_underflow && r_idx < arr_size) {
365 --res.m_arr[arr_size - 1 - r_idx];
366 for (
int i = arr_size - 1 - r_idx - 1; i >= 0; --i) {
367 if (res.m_arr[i + 1] == std::numeric_limits<base_type>::max()) {
378 template <
typename T>
379 constexpr static wide_integer<Bits, Signed> _operator_plus_T(
const wide_integer<Bits, Signed> &lhs,
380 T
rhs)
noexcept(is_same<Signed, unsigned>::value) {
381 wide_integer<Bits, Signed> res = lhs;
383 bool is_overflow =
false;
385 for (;
static_cast<size_t>(r_idx) <
sizeof(T) && r_idx < arr_size; ++r_idx) {
386 base_type &res_i = res.m_arr[arr_size - 1 - r_idx];
387 base_type curr_rhs =
static_cast<base_type>((
rhs >> (r_idx * CHAR_BIT))) & std::numeric_limits<base_type>::max();
391 is_overflow = res_i == 0;
394 res_i =
static_cast<base_type>(res_i + curr_rhs);
395 if (res_i < curr_rhs) {
400 if (is_overflow && r_idx < arr_size) {
401 ++res.m_arr[arr_size - 1 - r_idx];
402 for (
int i = arr_size - 1 - r_idx - 1; i >= 0; --i) {
403 if (res.m_arr[i + 1] == 0) {
415 constexpr static wide_integer<Bits, Signed> operator_unary_tilda(
const wide_integer<Bits, Signed> &lhs)
noexcept {
416 wide_integer<Bits, Signed> res{};
417 for (
int i = 0; i < arr_size; ++i) {
418 res.m_arr[i] =
static_cast<base_type>(lhs.m_arr[i]);
423 constexpr static wide_integer<Bits, Signed>
424 operator_unary_minus(
const wide_integer<Bits, Signed> &lhs)
noexcept(is_same<Signed, unsigned>::value) {
425 return operator_plus_T(operator_unary_tilda(lhs), 1);
428 template <
typename T,
class = __keep_size<T>>
429 constexpr static wide_integer<Bits, Signed> operator_plus(
const wide_integer<Bits, Signed> &lhs,
430 const T &
rhs)
noexcept(is_same<Signed, unsigned>::value) {
431 wide_integer<Bits, Signed> t =
rhs;
432 if (is_negative(t)) {
433 return _operator_minus_wide_integer(lhs, operator_unary_minus(t));
435 return _operator_plus_wide_integer(lhs, t);
458 template <
typename T,
class = __keep_size<T>>
459 constexpr static wide_integer<Bits, Signed> operator_minus(
const wide_integer<Bits, Signed> &lhs,
460 const T &
rhs)
noexcept(is_same<Signed, unsigned>::value) {
461 wide_integer<Bits, Signed> t =
rhs;
462 if (is_negative(t)) {
463 return _operator_plus_wide_integer(lhs, operator_unary_minus(t));
465 return _operator_minus_wide_integer(lhs, t);
481 constexpr static wide_integer<Bits, Signed>
482 _operator_minus_wide_integer(
const wide_integer<Bits, Signed> &lhs,
483 const wide_integer<Bits, Signed> &
rhs)
noexcept(is_same<Signed, unsigned>::value) {
484 wide_integer<Bits, Signed> res = lhs;
486 bool is_underflow =
false;
487 for (
int idx = arr_size - 1; idx >= 0; --idx) {
493 is_underflow = res_i == std::numeric_limits<base_type>::max();
499 res_i =
static_cast<base_type>(res_i - rhs_i);
505 constexpr static wide_integer<Bits, Signed>
506 _operator_plus_wide_integer(
const wide_integer<Bits, Signed> &lhs,
507 const wide_integer<Bits, Signed> &
rhs)
noexcept(is_same<Signed, unsigned>::value) {
508 wide_integer<Bits, Signed> res = lhs;
510 bool is_overflow =
false;
511 for (
int idx = arr_size - 1; idx >= 0; --idx) {
517 is_overflow = res_i == 0;
520 res_i =
static_cast<base_type>(res_i + rhs_i);
530 template <
typename T,
class = __keep_size<T>>
531 constexpr static wide_integer<Bits, Signed> operator_star(
const wide_integer<Bits, Signed> &lhs,
const T &
rhs) {
532 const wide_integer<Bits, unsigned> a = make_positive(lhs);
533 wide_integer<Bits, unsigned> t = make_positive(wide_integer<Bits, Signed>(
rhs));
535 wide_integer<Bits, Signed> res = 0;
537 for (
size_t i = 0; i < arr_size * base_bits; ++i) {
538 if (t.m_arr[arr_size - 1] & 1) {
539 res = operator_plus(res, shift_left(a, i));
542 t = shift_right(t, 1);
545 if (is_same<Signed, signed>::value && is_negative(wide_integer<Bits, Signed>(
rhs)) != is_negative(lhs)) {
546 res = operator_unary_minus(res);
562 template <
typename T,
class = __keep_size<T>>
563 constexpr static bool operator_more(
const wide_integer<Bits, Signed> &lhs,
const T &
rhs)
noexcept {
568 wide_integer<Bits, Signed> t =
rhs;
570 if (std::numeric_limits<T>::is_signed && (is_negative(lhs) != is_negative(t))) {
571 return is_negative(t);
574 for (
int i = 0; i < arr_size; ++i) {
575 if (lhs.m_arr[i] != t.m_arr[i]) {
576 return lhs.m_arr[i] > t.m_arr[i];
592 template <
typename T,
class = __keep_size<T>>
593 constexpr static bool operator_less(
const wide_integer<Bits, Signed> &lhs,
const T &
rhs)
noexcept {
598 wide_integer<Bits, Signed> t =
rhs;
600 if (std::numeric_limits<T>::is_signed && (is_negative(lhs) != is_negative(t))) {
601 return is_negative(lhs);
604 for (
int i = 0; i < arr_size; ++i) {
605 if (lhs.m_arr[i] != t.m_arr[i]) {
606 return lhs.m_arr[i] < t.m_arr[i];
622 template <
typename T,
class = __keep_size<T>>
623 constexpr static bool operator_eq(
const wide_integer<Bits, Signed> &lhs,
const T &
rhs)
noexcept {
624 wide_integer<Bits, Signed> t =
rhs;
626 for (
int i = 0; i < arr_size; ++i) {
627 if (lhs.m_arr[i] != t.m_arr[i]) {
644 template <
typename T,
class = __keep_size<T>>
645 constexpr static wide_integer<Bits, Signed> operator_pipe(
const wide_integer<Bits, Signed> &lhs,
646 const T &
rhs)
noexcept {
647 wide_integer<Bits, Signed> t =
rhs;
648 wide_integer<Bits, Signed> res = lhs;
650 for (
int i = 0; i < arr_size; ++i) {
651 res.m_arr[i] |= t.m_arr[i];
668 template <
typename T,
class = __keep_size<T>>
669 constexpr static wide_integer<Bits, Signed> operator_amp(
const wide_integer<Bits, Signed> &lhs,
670 const T &
rhs)
noexcept {
671 wide_integer<Bits, Signed> t =
rhs;
672 wide_integer<Bits, Signed> res = lhs;
674 for (
int i = 0; i < arr_size; ++i) {
675 res.m_arr[i] &= t.m_arr[i];
691 template <
typename T>
692 constexpr static void divide(
const T &lhserator,
const T &denominator, T "ient, T &remainder) {
694 std::all_of(std::cbegin(denominator.m_arr), std::cend(denominator.m_arr), [](
const auto &c) { return c == 0; });
697 throw std::domain_error(
"divide by zero");
705 while (!operator_more(d,
n) && operator_eq(operator_amp(shift_right(d, base_bits * arr_size - 1), 1), 0)) {
706 x = shift_left(x, 1);
707 d = shift_left(d, 1);
710 while (!operator_eq(x, 0)) {
711 if (!operator_more(d,
n)) {
712 n = operator_minus(
n, d);
713 answer = operator_pipe(answer, x);
716 x = shift_right(x, 1);
717 d = shift_right(d, 1);
725 template <
typename T,
class = __keep_size<T>>
726 constexpr static wide_integer<Bits, Signed> operator_slash(
const wide_integer<Bits, Signed> &lhs,
const T &
rhs) {
727 wide_integer<Bits, Signed> o =
rhs;
728 wide_integer<Bits, Signed> quotient{}, remainder{};
729 divide(make_positive(lhs), make_positive(o), quotient, remainder);
731 if (is_same<Signed, signed>::value && is_negative(o) != is_negative(lhs)) {
732 quotient = operator_unary_minus(quotient);
748 template <
typename T,
class = __keep_size<T>>
749 constexpr static wide_integer<Bits, Signed> operator_percent(
const wide_integer<Bits, Signed> &lhs,
const T &
rhs) {
750 wide_integer<Bits, Signed> o =
rhs;
751 wide_integer<Bits, Signed> quotient{}, remainder{};
752 divide(make_positive(lhs), make_positive(o), quotient, remainder);
753 if (is_same<Signed, signed>::value && is_negative(lhs)) {
754 remainder = operator_unary_minus(remainder);
770 template <
typename T,
class = __keep_size<T>>
771 constexpr static wide_integer<Bits, Signed> operator_circumflex(
const wide_integer<Bits, Signed> &lhs,
772 const T &
rhs)
noexcept {
773 wide_integer<Bits, Signed> t(
rhs);
774 wide_integer<Bits, Signed> res = lhs;
776 for (
int i = 0; i < arr_size; ++i) {
777 res.m_arr[i] ^= t.m_arr[i];
792 constexpr static wide_integer<Bits, Signed> from_str(
const char *c) {
793 wide_integer<Bits, Signed> res = 0;
795 bool is_neg = is_same<Signed, signed>::value && *c ==
'-';
800 if (*c ==
'0' && (*(c + 1) ==
'x' || *(c + 1) ==
'X')) {
804 if (*c >=
'0' && *c <=
'9') {
805 res = operator_star(res, 16U);
806 res = operator_plus_T(res, *c -
'0');
808 }
else if (*c >=
'a' && *c <=
'f') {
809 res = operator_star(res, 16U);
810 res = operator_plus_T(res, *c -
'a' + 10U);
812 }
else if (*c >=
'A' && *c <=
'F') {
813 res = operator_star(res, 16U);
814 res = operator_plus_T(res, *c -
'A' + 10U);
817 throw std::runtime_error(
"invalid char from");
822 if (*c < '0' || *c >
'9') {
823 throw std::runtime_error(
"invalid char from");
825 res = operator_star(res, 10U);
826 res = operator_plus_T(res, *c -
'0');
832 res = operator_unary_minus(res);
838 constexpr static wide_integer<Bits, Signed> from_str(
const wchar_t *c) {
839 wide_integer<Bits, Signed> res = 0;
841 bool is_neg = is_same<Signed, signed>::value && *c ==
L'-';
846 if (*c == L
'0' && (*(c + 1) == L
'x' || *(c + 1) == L
'X')) {
850 if (*c >= L
'0' && *c <= L
'9') {
851 res = operator_star(res, 16U);
852 res = operator_plus_T(res, *c - L
'0');
854 }
else if (*c >= L
'a' && *c <= L
'f') {
855 res = operator_star(res, 16U);
856 res = operator_plus_T(res, *c - L
'a' + 10U);
858 }
else if (*c >= L
'A' && *c <= L
'F') {
859 res = operator_star(res, 16U);
860 res = operator_plus_T(res, *c - L
'A' + 10U);
863 throw std::runtime_error(
"invalid char from");
868 if (*c < L'0' || *c > L
'9') {
869 throw std::runtime_error(
"invalid char from");
871 res = operator_star(res, 10U);
872 res = operator_plus_T(res, *c - L
'0');
878 res = operator_unary_minus(res);
887template <
size_t Bits,
typename Signed>
890 _impl::wide_integer_from_bultin(*
this,
rhs);
893template <
size_t Bits,
typename Signed>
894template <
size_t Bits2,
typename Signed2>
896 _impl::wide_integer_from_wide_integer(*
this,
rhs);
899template <
size_t Bits,
typename Signed>
900template <
size_t Bits2,
typename Signed2>
901constexpr wide_integer<Bits, Signed> &
903 _impl::wide_integer_from_wide_integer(*
this,
rhs);
907template <
size_t Bits,
typename Signed>
910 _impl::wide_integer_from_bultin(*
this,
rhs);
914template <
size_t Bits,
typename Signed>
921template <
size_t Bits,
typename Signed>
928template <
size_t Bits,
typename Signed>
930constexpr wide_integer<Bits, Signed> &
936template <
size_t Bits,
typename Signed>
938constexpr wide_integer<Bits, Signed> &
944template <
size_t Bits,
typename Signed>
951template <
size_t Bits,
typename Signed>
958template <
size_t Bits,
typename Signed>
965template <
size_t Bits,
typename Signed>
972template <
size_t Bits,
typename Signed>
973template <
typename T2,
typename>
975 *
this = _impl::shift_left(*
this,
n);
979template <
size_t Bits,
typename Signed>
980template <
typename T2,
typename>
982 *
this = _impl::shift_right(*
this,
n);
986template <
size_t Bits,
typename Signed>
987constexpr wide_integer<Bits, Signed> &
989 *
this = _impl::operator_plus(*
this, 1);
993template <
size_t Bits,
typename Signed>
994constexpr wide_integer<Bits, Signed>
997 *
this = _impl::operator_plus(*
this, 1);
1001template <
size_t Bits,
typename Signed>
1002constexpr wide_integer<Bits, Signed> &
1004 *
this = _impl::operator_minus(*
this, 1);
1008template <
size_t Bits,
typename Signed>
1009constexpr wide_integer<Bits, Signed>
1012 *
this = _impl::operator_minus(*
this, 1);
1016template <
size_t Bits,
typename Signed>
constexpr wide_integer<Bits, Signed>::operator bool() const noexcept {
1017 return !_impl::operator_eq(*
this, 0);
1020template <
size_t Bits,
typename Signed>
1021template <
class T,
class>
1022constexpr wide_integer<Bits, Signed>::operator T() const noexcept {
1023 static_assert(std::numeric_limits<T>::is_integer,
"");
1025 for (
size_t r_idx = 0; r_idx < _impl::arr_size && r_idx <
sizeof(T) /
sizeof(base_type); ++r_idx) {
1026 res |= (T(m_arr[_impl::arr_size - 1 - r_idx]) << (_impl::base_bits * r_idx *
sizeof(base_type)));
1031template <
size_t Bits,
typename Signed>
constexpr wide_integer<Bits, Signed>::operator
long double() const noexcept {
1032 if (_impl::operator_eq(*
this, 0)) {
1036 wide_integer<Bits, Signed>
tmp = *
this;
1037 if (_impl::is_negative(*
this)) {
1041 long double res = 0;
1042 for (
size_t idx = 0; idx < _impl::arr_size; ++idx) {
1043 long double t = res;
1044 res *= std::numeric_limits<base_type>::max();
1046 res +=
tmp.m_arr[idx];
1049 if (_impl::is_negative(*
this)) {
1056template <
size_t Bits,
typename Signed>
constexpr wide_integer<Bits, Signed>::operator double() const noexcept {
1057 return static_cast<long double>(*this);
1060template <
size_t Bits,
typename Signed>
constexpr wide_integer<Bits, Signed>::operator float() const noexcept {
1061 return static_cast<long double>(*this);
1065template <
size_t Bits,
typename Signed>
1066constexpr wide_integer<Bits, Signed>
operator~(
const wide_integer<Bits, Signed> &lhs)
noexcept {
1067 return wide_integer<Bits, Signed>::_impl::operator_unary_tilda(lhs);
1070template <
size_t Bits,
typename Signed>
1071constexpr wide_integer<Bits, Signed>
1072operator-(
const wide_integer<Bits, Signed> &lhs)
noexcept(is_same<Signed, unsigned>::value) {
1073 return wide_integer<Bits, Signed>::_impl::operator_unary_minus(lhs);
1076template <
size_t Bits,
typename Signed>
1077constexpr wide_integer<Bits, Signed>
1078operator+(
const wide_integer<Bits, Signed> &lhs)
noexcept(is_same<Signed, unsigned>::value) {
1083template <
size_t Bits,
typename Signed,
size_t Bits2,
typename Signed2>
1084std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>
constexpr
1085operator*(
const wide_integer<Bits, Signed> &lhs,
const wide_integer<Bits2, Signed2> &
rhs) {
1086 return std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>::_impl::operator_star(lhs,
rhs);
1089template <
typename Arithmetic,
typename Arithmetic2,
class>
1090std::common_type_t<Arithmetic, Arithmetic2>
constexpr operator*(
const Arithmetic &lhs,
const Arithmetic2 &
rhs) {
1091 return CT(lhs) * CT(
rhs);
1094template <
size_t Bits,
typename Signed,
size_t Bits2,
typename Signed2>
1095std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>
constexpr
1096operator/(
const wide_integer<Bits, Signed> &lhs,
const wide_integer<Bits2, Signed2> &
rhs) {
1097 return std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>::_impl::operator_slash(lhs,
rhs);
1099template <
typename Arithmetic,
typename Arithmetic2,
class>
1100std::common_type_t<Arithmetic, Arithmetic2>
constexpr operator/(
const Arithmetic &lhs,
const Arithmetic2 &
rhs) {
1101 return CT(lhs) / CT(
rhs);
1104template <
size_t Bits,
typename Signed,
size_t Bits2,
typename Signed2>
1105std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>
constexpr
1106operator+(
const wide_integer<Bits, Signed> &lhs,
const wide_integer<Bits2, Signed2> &
rhs) {
1107 return std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>::_impl::operator_plus(lhs,
rhs);
1109template <
typename Arithmetic,
typename Arithmetic2,
class>
1110std::common_type_t<Arithmetic, Arithmetic2>
constexpr operator+(
const Arithmetic &lhs,
const Arithmetic2 &
rhs) {
1111 return CT(lhs) + CT(
rhs);
1114template <
size_t Bits,
typename Signed,
size_t Bits2,
typename Signed2>
1115std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>
constexpr
1116operator-(
const wide_integer<Bits, Signed> &lhs,
const wide_integer<Bits2, Signed2> &
rhs) {
1117 return std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>::_impl::operator_minus(lhs,
rhs);
1119template <
typename Arithmetic,
typename Arithmetic2,
class>
1120std::common_type_t<Arithmetic, Arithmetic2>
constexpr operator-(
const Arithmetic &lhs,
const Arithmetic2 &
rhs) {
1121 return CT(lhs) - CT(
rhs);
1124template <
size_t Bits,
typename Signed,
size_t Bits2,
typename Signed2>
1125std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>
constexpr
1126operator%(
const wide_integer<Bits, Signed> &lhs,
const wide_integer<Bits2, Signed2> &
rhs) {
1127 return std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>::_impl::operator_percent(lhs,
1130template <
typename Integral,
typename Integral2,
class>
1131std::common_type_t<Integral, Integral2>
constexpr operator%(
const Integral &lhs,
const Integral2 &
rhs) {
1132 return CT(lhs) % CT(
rhs);
1135template <
size_t Bits,
typename Signed,
size_t Bits2,
typename Signed2>
1136std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>
constexpr
1137operator&(
const wide_integer<Bits, Signed> &lhs,
const wide_integer<Bits2, Signed2> &
rhs) {
1138 return std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>::_impl::operator_amp(lhs,
rhs);
1140template <
typename Integral,
typename Integral2,
class>
1141std::common_type_t<Integral, Integral2>
constexpr operator&(
const Integral &lhs,
const Integral2 &
rhs) {
1142 return CT(lhs) & CT(
rhs);
1145template <
size_t Bits,
typename Signed,
size_t Bits2,
typename Signed2>
1146std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>
constexpr
1147operator|(
const wide_integer<Bits, Signed> &lhs,
const wide_integer<Bits2, Signed2> &
rhs) {
1148 return std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>::_impl::operator_pipe(lhs,
rhs);
1150template <
typename Integral,
typename Integral2,
class>
1151std::common_type_t<Integral, Integral2>
constexpr operator|(
const Integral &lhs,
const Integral2 &
rhs) {
1152 return CT(lhs) | CT(
rhs);
1155template <
size_t Bits,
typename Signed,
size_t Bits2,
typename Signed2>
1156std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>
constexpr
1157operator^(
const wide_integer<Bits, Signed> &lhs,
const wide_integer<Bits2, Signed2> &
rhs) {
1158 return std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>::_impl::operator_circumflex(lhs,
1161template <
typename Integral,
typename Integral2,
class>
1162std::common_type_t<Integral, Integral2>
constexpr operator^(
const Integral &lhs,
const Integral2 &
rhs) {
1163 return CT(lhs) ^ CT(
rhs);
1166template <
size_t Bits,
typename Signed>
1167constexpr wide_integer<Bits, Signed>
operator<<(
const wide_integer<Bits, Signed> &lhs,
int n)
noexcept {
1168 return wide_integer<Bits, Signed>::_impl::shift_left(lhs,
n);
1170template <
size_t Bits,
typename Signed>
1171constexpr wide_integer<Bits, Signed>
operator>>(
const wide_integer<Bits, Signed> &lhs,
int n)
noexcept {
1172 return wide_integer<Bits, Signed>::_impl::shift_right(lhs,
n);
1175template <
size_t Bits,
typename Signed,
size_t Bits2,
typename Signed2>
1176constexpr bool operator<(
const wide_integer<Bits, Signed> &lhs,
const wide_integer<Bits2, Signed2> &
rhs) {
1177 return std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>::_impl::operator_less(lhs,
rhs);
1179template <
typename Arithmetic,
typename Arithmetic2,
class>
1180constexpr bool operator<(
const Arithmetic &lhs,
const Arithmetic2 &
rhs) {
1181 return CT(lhs) < CT(
rhs);
1184template <
size_t Bits,
typename Signed,
size_t Bits2,
typename Signed2>
1185constexpr bool operator>(
const wide_integer<Bits, Signed> &lhs,
const wide_integer<Bits2, Signed2> &
rhs) {
1186 return std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>::_impl::operator_more(lhs,
rhs);
1188template <
typename Arithmetic,
typename Arithmetic2,
class>
1189constexpr bool operator>(
const Arithmetic &lhs,
const Arithmetic2 &
rhs) {
1190 return CT(lhs) > CT(
rhs);
1193template <
size_t Bits,
typename Signed,
size_t Bits2,
typename Signed2>
1194constexpr bool operator<=(
const wide_integer<Bits, Signed> &lhs,
const wide_integer<Bits2, Signed2> &
rhs) {
1195 return std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>::_impl::operator_less(lhs,
rhs) ||
1196 std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>::_impl::operator_eq(lhs,
rhs);
1198template <
typename Arithmetic,
typename Arithmetic2,
class>
1199constexpr bool operator<=(
const Arithmetic &lhs,
const Arithmetic2 &
rhs) {
1200 return CT(lhs) <= CT(
rhs);
1203template <
size_t Bits,
typename Signed,
size_t Bits2,
typename Signed2>
1204constexpr bool operator>=(
const wide_integer<Bits, Signed> &lhs,
const wide_integer<Bits2, Signed2> &
rhs) {
1205 return std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>::_impl::operator_more(lhs,
rhs) ||
1206 std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>::_impl::operator_eq(lhs,
rhs);
1208template <
typename Arithmetic,
typename Arithmetic2,
class>
1209constexpr bool operator>=(
const Arithmetic &lhs,
const Arithmetic2 &
rhs) {
1210 return CT(lhs) >= CT(
rhs);
1213template <
size_t Bits,
typename Signed,
size_t Bits2,
typename Signed2>
1214constexpr bool operator==(
const wide_integer<Bits, Signed> &lhs,
const wide_integer<Bits2, Signed2> &
rhs) {
1215 return std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>::_impl::operator_eq(lhs,
rhs);
1217template <
typename Arithmetic,
typename Arithmetic2,
class>
1218constexpr bool operator==(
const Arithmetic &lhs,
const Arithmetic2 &
rhs) {
1219 return CT(lhs) == CT(
rhs);
1222template <
size_t Bits,
typename Signed,
size_t Bits2,
typename Signed2>
1223constexpr bool operator!=(
const wide_integer<Bits, Signed> &lhs,
const wide_integer<Bits2, Signed2> &
rhs) {
1224 return !std::common_type_t<wide_integer<Bits, Signed>, wide_integer<Bits2, Signed2>>::_impl::operator_eq(lhs,
rhs);
1226template <
typename Arithmetic,
typename Arithmetic2,
class>
1227constexpr bool operator!=(
const Arithmetic &lhs,
const Arithmetic2 &
rhs) {
1228 return CT(lhs) != CT(
rhs);
1231template <
size_t Bits,
typename Signed> std::string
to_string(
const wide_integer<Bits, Signed> &
n) {
1233 if (wide_integer<Bits, Signed>::_impl::operator_eq(
n, 0U)) {
1237 wide_integer<Bits, unsigned> t;
1238 bool is_neg = wide_integer<Bits, Signed>::_impl::is_negative(
n);
1240 t = wide_integer<Bits, Signed>::_impl::operator_unary_minus(
n);
1245 while (!wide_integer<Bits, unsigned>::_impl::operator_eq(t, 0U)) {
1246 res.insert(res.begin(),
'0' +
char(wide_integer<Bits, unsigned>::_impl::operator_percent(t, 10U)));
1247 t = wide_integer<Bits, unsigned>::_impl::operator_slash(t, 10U);
1251 res.insert(res.begin(),
'-');
1257template <
size_t Bits,
typename Signed> std::wstring
to_wstring(
const wide_integer<Bits, Signed> &
n) {
1259 if (wide_integer<Bits, Signed>::_impl::operator_eq(
n, 0U)) {
1263 wide_integer<Bits, unsigned> t;
1264 bool is_neg = wide_integer<Bits, Signed>::_impl::is_negative(
n);
1266 t = wide_integer<Bits, Signed>::_impl::operator_unary_minus(
n);
1271 while (!wide_integer<Bits, unsigned>::_impl::operator_eq(t, 0U)) {
1272 res.insert(res.begin(),
'0' +
wchar_t(wide_integer<Bits, unsigned>::_impl::operator_percent(t, 10U)));
1273 t = wide_integer<Bits, unsigned>::_impl::operator_slash(t, 10U);
1277 res.insert(res.begin(),
'-');
1283template <
size_t Bits,
typename Signed>
1284std::ostream &
operator<<(std::ostream &out,
const wide_integer<Bits, Signed> &
n) {
1289template <
size_t Bits,
typename Signed>
1290std::wostream &
operator<<(std::wostream &out,
const wide_integer<Bits, Signed> &
n) {
1295template <
size_t Bits,
typename Signed> std::istream &
operator>>(std::istream &in, wide_integer<Bits, Signed> &
n) {
1298 n = wide_integer<Bits, Signed>::_impl::from_str(s.c_str());
1302template <
size_t Bits,
typename Signed> std::wistream &
operator>>(std::wistream &in, wide_integer<Bits, Signed> &
n) {
1305 n = wide_integer<Bits, Signed>::_impl::from_str(s.c_str());
1309template <
size_t Bits,
typename Signed>
1310to_chars_result
to_chars(
char *first,
char *last,
const wide_integer<Bits, Signed> &
value,
int base) {
1311 if (base < 2 || base > 36) {
1312 return {last, std::make_error_code(std::errc::invalid_argument)};
1314 if (first >= last) {
1315 return {last, std::make_error_code(std::errc::invalid_argument)};
1321 return {++first, {}};
1324 wide_integer<Bits, Signed> v =
value;
1332 while (v != 0 && --cur >= first) {
1333 static const char ALPHA[] =
"0123456789abcdefghijklmnopqrstuvwxyz";
1334 *cur = ALPHA[v % base];
1338 if (v && cur + 1 == first) {
1339 return {
nullptr, std::make_error_code(std::errc::value_too_large)};
1342 while (cur < last) {
1343 *(first++) = *(cur++);
1352std::array<char, 256>
inline genReverseAlpha() noexcept {
1353 static const char ALPHA[] =
"0123456789abcdefghijklmnopqrstuvwxyz";
1354 std::array<char, 256> res;
1356 for (
size_t i = 0; i <
sizeof(ALPHA); ++i) {
1357 res[ALPHA[i]] =
static_cast<char>(i);
1362template <
size_t Bits,
typename Signed>
1363from_chars_result
from_chars(
const char *first,
const char *last, wide_integer<Bits, Signed> &
value,
int base) {
1364 if (base < 2 || base > 36) {
1365 return {first, std::make_error_code(std::errc::invalid_argument)};
1367 if (first >= last) {
1368 return {first, std::make_error_code(std::errc::invalid_argument)};
1371 bool is_negative = *first ==
'-';
1373 if (!is_same<Signed, signed>::value) {
1374 return {first, std::make_error_code(std::errc::result_out_of_range)};
1376 if (++first >= last) {
1377 return {first, std::make_error_code(std::errc::invalid_argument)};
1381 wide_integer<Bits, Signed> v = 0;
1382 const char *cur = first;
1385 static const std::array<char, 256> ALPHA = genReverseAlpha();
1386 char cv = ALPHA[*cur];
1387 if (cv >= base || cv == -1) {
1389 return {cur, std::make_error_code(std::errc::result_out_of_range)};
1398 }
while (++cur < last);
1400 value = is_negative ? -v : v;
1404constexpr int128_t operator"" _cppi128(
const char *
n) {
return int128_t::_impl::from_str(
n); }
1405constexpr int256_t operator"" _cppi256(
const char *
n) {
return int256_t::_impl::from_str(
n); }
1406constexpr int512_t operator"" _cppi512(
const char *
n) {
return int512_t::_impl::from_str(
n); }
1407constexpr uint128_t operator"" _cppui128(
const char *
n) {
return uint128_t::_impl::from_str(
n); }
1408constexpr uint256_t operator"" _cppui256(
const char *
n) {
return uint256_t::_impl::from_str(
n); }
1409constexpr uint512_t operator"" _cppui512(
const char *
n) {
return uint512_t::_impl::from_str(
n); }
1411template <
size_t Bits,
typename Signed>
struct hash<wide_integer<Bits, Signed>> {
1412 std::size_t operator()(
const wide_integer<Bits, Signed> &lhs)
const {
1413 size_t res = std::accumulate(std::cbegin(lhs.m_arr), std::cend(lhs.m_arr), 0);
1414 return hash<size_t>()(res);
const std::vector< double > & rhs
double value
The value of the point.
constexpr wide_integer< Bits, Signed > & operator>>=(T2 n) noexcept
constexpr wide_integer< Bits, Signed > & operator<<=(T2 n) noexcept
constexpr wide_integer< Bits, Signed > & operator++() noexcept(is_same< Signed, unsigned >::value)
constexpr wide_integer< Bits, Signed > & operator&=(const Integral &rhs) noexcept
constexpr wide_integer< Bits, Signed > & operator*=(const Arithmetic &rhs)
constexpr wide_integer< Bits, Signed > & operator|=(const Integral &rhs) noexcept
constexpr wide_integer< Bits, Signed > & operator--() noexcept(is_same< Signed, unsigned >::value)
friend class wide_integer
constexpr wide_integer< Bits, Signed > & operator=(const wide_integer< Bits2, Signed2 > &rhs) noexcept
constexpr wide_integer< Bits, Signed > & operator+=(const Arithmetic &rhs) noexcept(is_same< Signed, unsigned >::value)
constexpr wide_integer< Bits, Signed > & operator-=(const Arithmetic &rhs) noexcept(is_same< Signed, unsigned >::value)
constexpr wide_integer< Bits, Signed > & operator%=(const Integral &rhs)
constexpr wide_integer< Bits, Signed > & operator^=(const Integral &rhs) noexcept
constexpr wide_integer< Bits, Signed > & operator/=(const Arithmetic &rhs)
wide_uint< 512 > uint512_t
wide_uint< 256 > uint256_t
wide_uint< 128 > uint128_t
constexpr wide_integer< Bits, Signed > operator-(const wide_integer< Bits, Signed > &lhs) noexcept(is_same< Signed, unsigned >::value)
static constexpr bool ArithmeticConcept() noexcept
constexpr bool operator==(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
static constexpr bool IntegralConcept() noexcept
std::common_type_t< wide_integer< Bits, Signed >, wide_integer< Bits2, Signed2 > > constexpr operator|(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
from_chars_result from_chars(const char *first, const char *last, wide_integer< Bits, Signed > &value, int base=10)
std::wstring to_wstring(const wide_integer< Bits, Signed > &n)
constexpr bool operator>=(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
std::common_type_t< wide_integer< Bits, Signed >, wide_integer< Bits2, Signed2 > > constexpr operator%(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr bool operator!=(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
std::common_type_t< wide_integer< Bits, Signed >, wide_integer< Bits2, Signed2 > > constexpr operator*(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr wide_integer< Bits, Signed > operator+(const wide_integer< Bits, Signed > &lhs) noexcept(is_same< Signed, unsigned >::value)
to_chars_result to_chars(char *first, char *last, const wide_integer< Bits, Signed > &value, int base=10)
constexpr bool operator<=(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr bool operator>(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr wide_integer< Bits, Signed > operator~(const wide_integer< Bits, Signed > &lhs) noexcept
std::string to_string(const wide_integer< Bits, Signed > &n)
constexpr bool operator<(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
std::common_type_t< wide_integer< Bits, Signed >, wide_integer< Bits2, Signed2 > > constexpr operator/(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr wide_integer< Bits, Signed > operator>>(const wide_integer< Bits, Signed > &lhs, T2 n) noexcept
std::common_type_t< wide_integer< Bits, Signed >, wide_integer< Bits2, Signed2 > > constexpr operator&(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr wide_integer< Bits, Signed > operator<<(const wide_integer< Bits, Signed > &lhs, T2 n) noexcept
std::common_type_t< wide_integer< Bits, Signed >, wide_integer< Bits2, Signed2 > > constexpr operator^(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)