TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
Loading...
Searching...
No Matches
uint128_t.hpp
Go to the documentation of this file.
1
9
10#include <algorithm>
11#include <cstdint>
12#include <ostream>
13#include <string>
14#include <utility>
15
16#ifdef _MSC_VER
17#include <intrin.h>
18#endif
19
20#ifndef CIPHERS_UINT128_T_HPP_
21#define CIPHERS_UINT128_T_HPP_
22class uint128_t;
23
31std::string add(const std::string &first, const std::string &second) {
32 std::string third;
33 int16_t sum = 0, carry = 0;
34 for (int32_t i = static_cast<int32_t>(first.size()) - 1,
35 j = static_cast<int32_t>(second.size()) - 1;
36 i >= 0 || j >= 0; --i, --j) {
37 sum = ((i >= 0 ? first[i] - '0' : 0) + (j >= 0 ? second[j] - '0' : 0) +
38 carry);
39 carry = sum / 10;
40 sum %= 10;
41 third.push_back(sum + '0');
42 }
43 if (carry) {
44 third.push_back('1');
45 }
46 std::reverse(third.begin(), third.end());
47 return third;
48}
49
53class uint128_t {
54 uint64_t f{}, s{};
55
63 void __get_integer_from_string(const std::string &str) {
64 this->f = this->s = 0;
65 if (str.size() > 1 && str[1] == 'x') { // if hexadecimal
66 for (auto i = 2; i < str.size(); ++i) {
67 *this *= 16LL;
68 if (str[i] >= '0' && str[i] <= '9') {
69 *this += (str[i] - '0');
70 } else if (str[i] >= 'A' && str[i] <= 'F') {
71 *this += (str[i] - 'A' + 10);
72 } else if (str[i] >= 'a' && str[i] <= 'f') {
73 *this += (str[i] - 'a' + 10);
74 }
75 }
76 } else { // if decimal
77 for (auto &x : str) {
78 *this *= 10LL;
79 *this += (x - '0');
80 }
81 }
82 }
83
84 public:
85 uint128_t() = default;
86
92 template <typename T, typename = typename std::enable_if<
93 std::is_integral<T>::value, T>::type>
94 explicit uint128_t(T low) : s(low) {}
95
100 explicit uint128_t(const std::string &str) {
102 }
103
109 uint128_t(const uint64_t high, const uint64_t low) : f(high), s(low) {}
110
115 uint128_t(const uint128_t &num) = default;
116
121 uint128_t(uint128_t &&num) noexcept : f(num.f), s(num.s) {}
122
126 ~uint128_t() = default;
127
133 inline uint32_t _lez() {
134#ifndef _MSC_VER
135 if (f) {
136 return __builtin_clzll(f);
137 }
138 return 64 + __builtin_clzll(s);
139#else
140 unsigned long r = 0;
141 _BitScanForward64(&r, f);
142 if (r == 64) {
143 unsigned long l = 0;
144 _BitScanForward64(&l, s);
145 return 64 + l;
146 }
147 return r;
148#endif
149 }
150
156 inline uint32_t _trz() {
157#ifndef _MSC_VER
158 if (f) {
159 return __builtin_ctzll(f);
160 }
161 return 64 + __builtin_ctzll(s);
162#else
163 unsigned long r = 0;
164 _BitScanReverse64(&r, s);
165 if (r == 64) {
166 unsigned long l = 0;
167 _BitScanReverse64(&l, f);
168 return 64 + l;
169 }
170 return r;
171#endif
172 }
173
178 inline explicit operator bool() const { return (f || s); }
179
185 template <typename T, typename = typename std::enable_if<
186 std::is_integral<T>::value, T>::type>
187 inline explicit operator T() const {
188 return static_cast<T>(s);
189 }
190
195 inline uint64_t lower() const { return s; }
196
201 inline uint64_t upper() const { return f; }
202
209 template <typename T, typename = typename std::enable_if<
210 std::is_integral<T>::value, T>::type>
211 inline uint128_t &operator=(const T &p) {
212 this->s = p;
213 return *this;
214 }
215
221 inline uint128_t &operator=(const std::string &p) {
223 return *this;
224 }
225
231 inline uint128_t &operator=(const uint128_t &p) = default;
232
236 inline uint128_t &operator=(uint128_t &&p) = default;
237
244 template <typename T, typename = typename std::enable_if<
245 std::is_integral<T>::value, T>::type>
246 inline uint128_t operator+(const T p) {
247 return uint128_t(f + (p + s < s), p + s);
248 }
249
255 inline uint128_t operator+(const uint128_t &p) {
256 return uint128_t(f + (p.s + s < s) + p.f, p.s + s);
257 }
258
265 template <typename T, typename = typename std::enable_if<
266 std::is_integral<T>::value, T>::type>
267 inline uint128_t &operator+=(const T p) {
268 bool app = p + s < s;
269 this->f += app;
270 this->s += p;
271 return *this;
272 }
273
279 uint128_t &operator+=(const uint128_t &p) {
280 bool app = p.s + s < s;
281 f = f + app + p.f;
282 s = p.s + s;
283 return *this;
284 }
285
290 inline uint128_t &operator++() {
291 *this += 1;
292 return *this;
293 }
294
299 inline uint128_t operator++(int) {
300 ++*this;
301 return *this;
302 }
303
310 template <typename T, typename = typename std::enable_if<
311 std::is_integral<T>::value, T>::type>
312 inline uint128_t operator-(const T &p) {
313 bool app = p > s;
314 return uint128_t(f - app, s - p);
315 }
316
322 inline uint128_t operator-(const uint128_t &p) {
323 bool app = p.s > s;
324 return uint128_t(f - p.f - app, s - p.s);
325 }
326
331 inline uint128_t operator-() { return ~*this + uint128_t(1); }
332
337 inline uint128_t &operator--() {
338 *this -= 1;
339 return *this;
340 }
341
346 inline uint128_t operator--(int) {
347 --*this;
348 return *this;
349 }
350
357 template <typename T, typename = typename std::enable_if<
358 std::is_integral<T>::value, T>::type>
359 uint128_t &operator-=(const T &p) {
360 bool app = p > s;
361 f -= app;
362 s -= p;
363 return *this;
364 }
365
371 uint128_t &operator-=(const uint128_t &p) {
372 bool app = p.s > s;
373 f = f - p.f - app;
374 s = s - p.s;
375 return *this;
376 }
377
384 template <typename T, typename = typename std::enable_if<
385 std::is_integral<T>::value, T>::type>
386 inline uint128_t operator*(const T p) {
387 return *this * uint128_t(p);
388 }
389
395 uint128_t operator*(const uint128_t &p) {
396 uint64_t f_first = s >> 32, f_second = s & 0xFFFFFFFF,
397 s_first = p.s >> 32, s_second = p.s & 0xFFFFFFFF;
398 uint64_t fi = f_first * s_first, se = f_first * s_second,
399 th = s_first * f_second, fo = s_second * f_second;
400 uint64_t tmp = ((se & 0xFFFFFFFF) << 32), tmp2 = (th & 0xFFFFFFFF)
401 << 32;
402 int cc = (tmp + tmp2 < tmp);
403 tmp += tmp2;
404 cc += (tmp + fo < tmp);
405 uint64_t carry = fi + (se >> 32) + (th >> 32);
406 return uint128_t(this->f * p.s + this->s * p.f + carry + cc, tmp + fo);
407 }
408
415 template <typename T, typename = typename std::enable_if<
416 std::is_integral<T>::value, T>::type>
417 inline uint128_t &operator*=(const T p) {
418 *this *= uint128_t(p);
419 return *this;
420 }
421
427 uint128_t &operator*=(const uint128_t &p) {
428 uint64_t f_first = s >> 32, f_second = s & 0xFFFFFFFF,
429 s_first = p.s >> 32, s_second = p.s & 0xFFFFFFFF;
430 uint64_t fi = f_first * s_first, se = f_first * s_second,
431 th = s_first * f_second, fo = s_second * f_second;
432 uint64_t tmp = (se << 32), tmp2 = (th << 32);
433 int cc = (tmp + tmp2 < tmp);
434 tmp += tmp2;
435 cc += (tmp + fo < tmp);
436 uint64_t carry = fi + (se >> 32) + (th >> 32);
437 f = this->f * p.s + this->s * p.f + carry + cc;
438 s = tmp + fo;
439 return *this;
440 }
441
448 std::pair<uint128_t, uint128_t> divide(const uint128_t &p) {
449 if (*this < p) { // if this is less than divisor
450 return {uint128_t(0), *this};
451 } else if (*this == p) { // if this is equal to divisor
452 return {uint128_t(1), uint128_t(0)};
453 }
454 uint128_t tmp = p, tmp2 = *this;
455 uint16_t left = tmp._lez() - _lez();
456 tmp <<= left;
457 uint128_t quotient(0);
458 uint128_t zero(0);
459 while (tmp2 >= p) {
460 uint16_t shf = tmp2._lez() - tmp._lez();
461 if (shf) {
462 tmp >>= shf;
463 quotient <<= shf;
464 left -= shf;
465 }
466 if (tmp2 < tmp) {
467 tmp >>= 1;
468 quotient <<= 1;
469 --left;
470 }
471 tmp2 -= tmp;
472 ++quotient;
473 }
474 return {quotient << left, tmp2};
475 }
476
482 inline uint128_t operator/(const uint128_t &p) { return divide(p).first; }
483
490 template <typename T, typename = typename std::enable_if<
491 std::is_integral<T>::value, T>::type>
492 inline uint128_t operator/(const T p) {
493 uint128_t tmp = *this;
494 tmp /= uint128_t(0, p);
495 return tmp;
496 }
497
503 inline uint128_t &operator/=(const uint128_t &p) {
504 *this = divide(p).first;
505 return *this;
506 }
507
514 template <typename T, typename = typename std::enable_if<
515 std::is_integral<T>::value, T>::type>
516 inline uint128_t &operator/=(const T p) {
517 *this /= uint128_t(0, p);
518 return *this;
519 }
520
526 inline uint128_t operator%(const uint128_t &p) { return divide(p).second; }
527
534 template <typename T, typename = typename std::enable_if<
535 std::is_integral<T>::value, T>::type>
536 inline uint128_t operator%(const T &p) {
537 return *this % uint128_t(p);
538 }
539
545 inline uint128_t &operator%=(const uint128_t &p) {
546 *this = divide(p).second;
547 return *this;
548 }
549
556 template <typename T, typename = typename std::enable_if<
557 std::is_integral<T>::value, T>::type>
558 inline uint128_t &operator%=(const T &p) {
559 *this %= uint128_t(p);
560 return *this;
561 }
562
568 inline bool operator<(const uint128_t &other) {
569 return f < other.f || (f == other.f && s < other.s);
570 }
571
577 inline bool operator<=(const uint128_t &other) {
578 return f < other.f || (f == other.f && s <= other.s);
579 }
580
586 inline bool operator>(const uint128_t &other) {
587 return f > other.f || (f == other.f && s > other.s);
588 }
589
595 inline bool operator>=(const uint128_t &other) {
596 return (f > other.f) || (f == other.f && s >= other.s);
597 }
598
604 inline bool operator==(const uint128_t &other) {
605 return f == other.f && s == other.s;
606 }
607
613 inline bool operator!=(const uint128_t &other) {
614 return f != other.f || s != other.s;
615 }
616
621 inline bool operator!() { return !f && !s; }
622
628 inline bool operator&&(const uint128_t &b) {
629 return (s || f) && (b.s || b.f);
630 }
631
637 inline bool operator||(const uint128_t &b) {
638 return (s || f) || (b.s || b.f);
639 }
640
645 inline bool operator()() { return s || f; }
646
653 template <typename T, typename = typename std::enable_if<
654 std::is_integral<T>::value, T>::type>
655 inline bool operator<(const T other) {
656 return *this < uint128_t(other);
657 }
658
665 template <typename T, typename = typename std::enable_if<
666 std::is_integral<T>::value, T>::type>
667 inline bool operator<=(const T other) {
668 return *this <= uint128_t(other);
669 }
670
677 template <typename T, typename = typename std::enable_if<
678 std::is_integral<T>::value, T>::type>
679 inline bool operator>(const T other) {
680 return *this > uint128_t(other);
681 }
682
689 template <typename T, typename = typename std::enable_if<
690 std::is_integral<T>::value, T>::type>
691 inline bool operator>=(const T other) {
692 return *this >= uint128_t(other);
693 }
694
701 template <typename T, typename = typename std::enable_if<
702 std::is_integral<T>::value, T>::type>
703 inline bool operator==(const T other) {
704 return *this == uint128_t(other);
705 }
706
713 template <typename T, typename = typename std::enable_if<
714 std::is_integral<T>::value, T>::type>
715 inline bool operator!=(const T other) {
716 return *this != uint128_t(other);
717 }
718
725 template <typename T, typename = typename std::enable_if<
726 std::is_integral<T>::value, T>::type>
727 inline bool operator&&(const T b) {
728 return (f || s) && b;
729 }
730
738 template <typename T, typename = typename std::enable_if<
739 std::is_integral<T>::value, T>::type>
740 inline bool operator||(const T b) {
741 return (f || s) || b;
742 }
743
748 uint128_t operator~() { return uint128_t(~this->f, ~this->s); }
749
756 template <typename T, typename = typename std::enable_if<
757 std::is_integral<T>::value, T>::type>
758 uint128_t operator<<(const T p) {
759 if (!p) {
760 return uint128_t(f, s);
761 } else if (p >= 64 && p <= 128) {
762 return uint128_t((this->s << (p - 64)), 0);
763 } else if (p < 64 && p > 0) {
764 return uint128_t((this->f << p) + ((this->s >> (64 - p))),
765 this->s << p);
766 }
767 return uint128_t(0);
768 }
769
776 template <typename T, typename = typename std::enable_if<
777 std::is_integral<T>::value, T>::type>
778 uint128_t &operator<<=(const T p) {
779 if (p) {
780 if (p >= 64 && p <= 128) {
781 this->f = (this->s << (p - 64));
782 this->s = 0;
783 } else {
784 f = ((this->f << p) + (this->s >> (64 - p)));
785 s = (this->s << p);
786 }
787 }
788 return *this;
789 }
790
797 template <typename T, typename = typename std::enable_if<
798 std::is_integral<T>::value, T>::type>
799 uint128_t operator>>(const T p) {
800 if (!p) {
801 return uint128_t(this->f, this->s);
802 } else if (p >= 64 && p <= 128) {
803 return uint128_t(0, (this->f >> (p - 64)));
804 } else if (p < 64 && p > 0) {
805 return uint128_t((this->f >> p),
806 (this->s >> p) + (this->f << (64 - p)));
807 }
808 return uint128_t(0);
809 }
810
817 template <typename T, typename = typename std::enable_if<
818 std::is_integral<T>::value, T>::type>
819 uint128_t &operator>>=(const T p) {
820 if (p) {
821 if (p >= 64) {
822 f = 0;
823 s = (this->f >> (p - 64));
824 } else {
825 s = (this->s >> p) + (this->f << (64 - p));
826 f = (this->f >> p);
827 }
828 }
829 return *this;
830 }
831
837 inline uint128_t operator&(const uint128_t &p) {
838 return uint128_t(this->f & p.f, this->s & p.s);
839 }
840
847 template <typename T, typename = typename std::enable_if<
848 std::is_integral<T>::value, T>::type>
849 uint128_t operator&(const T p) {
850 uint128_t tmp = *this;
851 return tmp & uint128_t(p);
852 }
853
859 uint128_t &operator&=(const uint128_t &p) {
860 this->f &= p.f;
861 this->s &= p.s;
862 return *this;
863 }
864
871 template <typename T, typename = typename std::enable_if<
872 std::is_integral<T>::value, T>::type>
873 uint128_t &operator&=(const T p) {
874 *this &= uint128_t(p);
875 return *this;
876 }
877
884 template <typename T, typename = typename std::enable_if<
885 std::is_integral<T>::value, T>::type>
886 inline uint128_t operator|(const T p) {
887 return uint128_t(p | s);
888 }
889
895 inline uint128_t operator|(const uint128_t &p) {
896 return uint128_t(this->f | p.f, this->s | p.s);
897 }
898
904 uint128_t &operator|=(const uint128_t &p) {
905 f |= p.f;
906 s |= p.s;
907 return *this;
908 }
909
916 template <typename T, typename = typename std::enable_if<
917 std::is_integral<T>::value, T>::type>
918 inline uint128_t &operator|=(const T p) {
919 s |= p.s;
920 return *this;
921 }
922
929 template <typename T, typename = typename std::enable_if<
930 std::is_integral<T>::value, T>::type>
931 inline uint128_t operator^(const T p) {
932 return uint128_t(this->f, this->s ^ p);
933 }
934
940 inline uint128_t operator^(const uint128_t &p) {
941 return uint128_t(this->f ^ p.f, this->s ^ p.s);
942 }
943
949 uint128_t &operator^=(const uint128_t &p) {
950 f ^= p.f;
951 s ^= p.s;
952 return *this;
953 }
954
961 template <typename T, typename = typename std::enable_if<
962 std::is_integral<T>::value, T>::type>
963 inline uint128_t &operator^=(const T &p) {
964 s ^= p;
965 return *this;
966 }
967
977 friend std::ostream &operator<<(std::ostream &op, const uint128_t &p) {
978 if (!p.f) {
979 op << p.s;
980 } else {
981 std::string out = "0", p_2 = "1";
982 for (int i = 0; i < 64; ++i) {
983 if (p.s & (1LL << i)) {
984 out = add(out, p_2);
985 }
986 p_2 = add(p_2, p_2);
987 }
988 for (int i = 0; i < 64; ++i) {
989 if (p.f & (1LL << i)) {
990 out = add(out, p_2);
991 }
992 p_2 = add(p_2, p_2);
993 }
994 op << out;
995 }
996 return op;
997 }
998};
999
1000// Arithmetic operators
1001template <typename T, typename = typename std::enable_if<
1002 std::is_integral<T>::value, T>::type>
1003inline uint128_t operator+(const T &p, const uint128_t &q) {
1004 return uint128_t(p) + q;
1005}
1006
1007template <typename T, typename = typename std::enable_if<
1008 std::is_integral<T>::value, T>::type>
1009inline uint128_t operator-(const T p, const uint128_t &q) {
1010 return uint128_t(p) - q;
1011}
1012
1013template <typename T, typename = typename std::enable_if<
1014 std::is_integral<T>::value, T>::type>
1015inline uint128_t operator*(const T p, const uint128_t &q) {
1016 return uint128_t(p) * q;
1017}
1018
1019template <typename T, typename = typename std::enable_if<
1020 std::is_integral<T>::value, T>::type>
1021inline uint128_t operator/(const T p, const uint128_t &q) {
1022 return uint128_t(p) / q;
1023}
1024
1025template <typename T, typename = typename std::enable_if<
1026 std::is_integral<T>::value, T>::type>
1027inline uint128_t operator%(const T p, const uint128_t &q) {
1028 return uint128_t(p) % q;
1029}
1030
1031// Bitwise operators
1032template <typename T, typename = typename std::enable_if<
1033 std::is_integral<T>::value, T>::type>
1034inline uint128_t operator&(const T &p, const uint128_t &q) {
1035 return uint128_t(p) & q;
1036}
1037
1038template <typename T, typename = typename std::enable_if<
1039 std::is_integral<T>::value, T>::type>
1040inline uint128_t operator|(const T p, const uint128_t &q) {
1041 return uint128_t(p) | q;
1042}
1043
1044template <typename T, typename = typename std::enable_if<
1045 std::is_integral<T>::value, T>::type>
1046inline uint128_t operator^(const T p, const uint128_t &q) {
1047 return uint128_t(p) ^ q;
1048}
1049
1050// Boolean operators
1051template <typename T, typename = typename std::enable_if<
1052 std::is_integral<T>::value, T>::type>
1053inline bool operator&&(const T p, const uint128_t &q) {
1054 return uint128_t(p) && q;
1055}
1056
1057template <typename T, typename = typename std::enable_if<
1058 std::is_integral<T>::value, T>::type>
1059inline bool operator||(const T p, const uint128_t &q) {
1060 return uint128_t(p) || q;
1061}
1062
1063// Comparison operators
1064template <typename T, typename = typename std::enable_if<
1065 std::is_integral<T>::value, T>::type>
1066inline bool operator==(const T p, const uint128_t &q) {
1067 return uint128_t(p) == q;
1068}
1069
1070template <typename T, typename = typename std::enable_if<
1071 std::is_integral<T>::value, T>::type>
1072inline bool operator!=(const T p, const uint128_t &q) {
1073 return uint128_t(p) != q;
1074}
1075
1076template <typename T, typename = typename std::enable_if<
1077 std::is_integral<T>::value, T>::type>
1078inline bool operator<(const T p, const uint128_t &q) {
1079 return uint128_t(p) < q;
1080}
1081
1082template <typename T, typename = typename std::enable_if<
1083 std::is_integral<T>::value, T>::type>
1084inline bool operator<=(const T p, const uint128_t &q) {
1085 return uint128_t(p) <= q;
1086}
1087
1088template <typename T, typename = typename std::enable_if<
1089 std::is_integral<T>::value, T>::type>
1090inline bool operator>(const T p, const uint128_t &q) {
1091 return uint128_t(p) > q;
1092}
1093
1094template <typename T, typename = typename std::enable_if<
1095 std::is_integral<T>::value, T>::type>
1096inline bool operator>=(const T p, const uint128_t &q) {
1097 return uint128_t(p) >= q;
1098}
1099
1100#endif // CIPHERS_UINT128_T_HPP_
class for 128-bit unsigned integer
Definition uint128_t.hpp:53
uint128_t & operator%=(const T &p)
operator %= for uint128_t
uint128_t operator-()
operator - using twos complement
uint128_t & operator-=(const T &p)
operator -= for uint128_t and other integer types.
bool operator&&(const T b)
operator && for other types
uint128_t & operator>>=(const T p)
operator >>= for uint128_t
uint128_t(const std::string &str)
Parameterized constructor.
uint128_t operator+(const uint128_t &p)
operator + for uint128_t and other integer types.
uint128_t operator<<(const T p)
operator << for uint128_t
bool operator<=(const uint128_t &other)
operator <= for uint128_t
uint128_t & operator--()
operator – (pre-decrement)
uint64_t upper() const
returns upper 64-bit integer part
uint128_t & operator&=(const T p)
operator &= for other types (bitwise operator)
uint128_t & operator%=(const uint128_t &p)
operator %= for uint128_t
bool operator>(const uint128_t &other)
operator > for uint128_t
uint128_t operator|(const uint128_t &p)
operator | for uint128_t (bitwise operator)
uint128_t & operator/=(const uint128_t &p)
operator /= for uint128_t
uint128_t & operator*=(const T p)
operator *= for uint128_t and other integer types.
uint128_t operator/(const uint128_t &p)
operator / for uint128_t and other integer types.
bool operator||(const uint128_t &b)
operator || for uint128_t
bool operator>=(const T other)
operator >= for other types
uint128_t & operator=(uint128_t &&p)=default
Move assignment operator.
uint128_t operator|(const T p)
operator | for other types (bitwise operator)
~uint128_t()=default
Destructor for uint128_t.
uint128_t operator~()
operator ~ for uint128_t
uint128_t operator*(const uint128_t &p)
operator * for uint128_t and other integer types.
uint128_t & operator^=(const T &p)
operator ^= for other types (bitwise operator)
bool operator<=(const T other)
operator <= for other types
uint128_t operator*(const T p)
operator * for uint128_t and other integer types.
uint128_t operator+(const T p)
operator + for uint128_t and other integer types.
uint128_t & operator+=(const T p)
operator += for uint128_t and other integer types.
bool operator<(const T other)
operator < for other types
friend std::ostream & operator<<(std::ostream &op, const uint128_t &p)
operator << for printing uint128_t integer
uint128_t(const uint128_t &num)=default
Copy constructor.
uint128_t & operator|=(const T p)
operator |= for other types (bitwise operator)
uint128_t operator-(const T &p)
operator - for uint128_t and other integer types.
uint128_t operator>>(const T p)
operator >> for uint128_t
uint128_t operator--(int)
operator – (post-decrement)
bool operator!=(const T other)
operator != for other types
bool operator==(const T other)
operator == for other types
bool operator==(const uint128_t &other)
operator == for uint128_t
uint32_t _trz()
Trailing zeroes in binary.
uint128_t(uint128_t &&num) noexcept
Move constructor.
bool operator||(const T b)
operator || for other types
uint128_t operator-(const uint128_t &p)
operator - for uint128_t
bool operator>(const T other)
operator > for other types
void __get_integer_from_string(const std::string &str)
First and second half of 128 bit number.
Definition uint128_t.hpp:63
std::pair< uint128_t, uint128_t > divide(const uint128_t &p)
divide function for uint128_t and other integer types.
uint128_t operator^(const uint128_t &p)
operator ^ for uint128_t (bitwise operator)
uint128_t(const uint64_t high, const uint64_t low)
Parameterized constructor.
uint128_t & operator*=(const uint128_t &p)
operator *= for uint128_t and other integer types.
uint128_t & operator+=(const uint128_t &p)
operator += for uint128_t
uint128_t operator&(const T p)
operator & for other types (bitwise operator)
uint128_t & operator<<=(const T p)
operator <<= for uint128_t
uint64_t lower() const
returns lower 64-bit integer part
uint128_t & operator/=(const T p)
operator /= for uint128_t and other integer types.
uint128_t operator^(const T p)
operator ^ for other types (bitwise operator)
bool operator&&(const uint128_t &b)
operator && for uint128_t
bool operator!=(const uint128_t &other)
operator != for uint128_t
uint128_t & operator=(const uint128_t &p)=default
operator = for uint128_t
uint128_t & operator|=(const uint128_t &p)
operator |= for uint128_t (bitwise operator)
uint128_t & operator=(const std::string &p)
operator = for type string
uint128_t & operator-=(const uint128_t &p)
operator -= for uint128_t
uint128_t operator%(const uint128_t &p)
operator % for uint128_t
uint128_t & operator&=(const uint128_t &p)
operator &= for uint128_t (bitwise operator)
uint128_t & operator++()
pre-increment operator
uint128_t & operator=(const T &p)
operator = for other types
bool operator<(const uint128_t &other)
operator < for uint128_t
uint128_t operator&(const uint128_t &p)
operator & for uint128_t (bitwise operator)
bool operator!()
operator ! for uint128_t
uint128_t(T low)
Parameterized constructor.
Definition uint128_t.hpp:94
uint128_t operator%(const T &p)
operator % for uint128_t and other integer types.
uint128_t & operator^=(const uint128_t &p)
operator ^= for uint128_t (bitwise operator)
bool operator>=(const uint128_t &other)
operator >= for uint128_t
uint128_t operator/(const T p)
operator / for uint128_t and other integer types.
uint32_t _lez()
Leading zeroes in binary.
bool operator()()
operator () for uint128_t
uint128_t operator++(int)
post-increment operator
std::string add(const std::string &first, const std::string &second)
Adding two string.
Definition uint128_t.hpp:31