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
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
24template <>
25struct std::is_integral<uint128_t> : std::true_type {};
26template <>
27struct std::is_arithmetic<uint128_t> : std::true_type {};
28template <>
29struct std::is_unsigned<uint128_t> : std::true_type {};
30
38std::string add(const std::string &first, const std::string &second) {
39 std::string third;
40 int16_t sum = 0, carry = 0;
41 for (int32_t i = static_cast<int32_t>(first.size()) - 1,
42 j = static_cast<int32_t>(second.size()) - 1;
43 i >= 0 || j >= 0; --i, --j) {
44 sum = ((i >= 0 ? first[i] - '0' : 0) + (j >= 0 ? second[j] - '0' : 0) +
45 carry);
46 carry = sum / 10;
47 sum %= 10;
48 third.push_back(sum + '0');
49 }
50 if (carry) {
51 third.push_back('1');
52 }
53 std::reverse(third.begin(), third.end());
54 return third;
55}
60class uint128_t {
61 uint64_t f{}, s{};
62
70 void __get_integer_from_string(const std::string &str) {
71 this->f = this->s = 0;
72 if (str.size() > 1 && str[1] == 'x') { // if hexadecimal
73 for (auto i = 2; i < str.size(); ++i) {
74 *this *= 16LL;
75 if (str[i] >= '0' && str[i] <= '9') {
76 *this += (str[i] - '0');
77 } else if (str[i] >= 'A' && str[i] <= 'F') {
78 *this += (str[i] - 'A' + 10);
79 } else if (str[i] >= 'a' && str[i] <= 'f') {
80 *this += (str[i] - 'a' + 10);
81 }
82 }
83 } else { // if decimal
84 for (auto &x : str) {
85 *this *= 10LL;
86 *this += (x - '0');
87 }
88 }
89 }
90
91 public:
92 uint128_t() = default;
93
99 template <typename T, typename = typename std::enable_if<
100 std::is_integral<T>::value, T>::type>
101 explicit uint128_t(T low) : s(low) {}
102
107 explicit uint128_t(const std::string &str) {
109 }
110
116 uint128_t(const uint64_t high, const uint64_t low) : f(high), s(low) {}
117
122 uint128_t(const uint128_t &num) = default;
123
128 uint128_t(uint128_t &&num) noexcept : f(num.f), s(num.s) {}
129
133 ~uint128_t() = default;
134
140 inline uint32_t _lez() {
141#ifndef _MSC_VER
142 if (f) {
143 return __builtin_clzll(f);
144 }
145 return 64 + __builtin_clzll(s);
146#else
147 unsigned long r = 0;
148 _BitScanForward64(&r, f);
149 if (r == 64) {
150 unsigned long l = 0;
151 _BitScanForward64(&l, s);
152 return 64 + l;
153 }
154 return r;
155#endif
156 }
157
163 inline uint32_t _trz() {
164#ifndef _MSC_VER
165 if (f) {
166 return __builtin_ctzll(f);
167 }
168 return 64 + __builtin_ctzll(s);
169#else
170 unsigned long r = 0;
171 _BitScanReverse64(&r, s);
172 if (r == 64) {
173 unsigned long l = 0;
174 _BitScanReverse64(&l, f);
175 return 64 + l;
176 }
177 return r;
178#endif
179 }
180
185 inline explicit operator bool() const { return (f || s); }
186
192 template <typename T, typename = typename std::enable_if<
193 std::is_integral<T>::value, T>::type>
194 inline explicit operator T() const {
195 return static_cast<T>(s);
196 }
197
202 inline uint64_t lower() const { return s; }
203
208 inline uint64_t upper() const { return f; }
209
216 template <typename T, typename = typename std::enable_if<
217 std::is_integral<T>::value, T>::type>
218 inline uint128_t &operator=(const T &p) {
219 this->s = p;
220 return *this;
221 }
222
228 inline uint128_t &operator=(const std::string &p) {
230 return *this;
231 }
232
238 inline uint128_t &operator=(const uint128_t &p) = default;
239
243 inline uint128_t &operator=(uint128_t &&p) = default;
244
251 template <typename T, typename = typename std::enable_if<
252 std::is_integral<T>::value, T>::type>
253 inline uint128_t operator+(const T p) {
254 return uint128_t(f + (p + s < s), p + s);
255 }
256
262 inline uint128_t operator+(const uint128_t &p) {
263 return uint128_t(f + (p.s + s < s) + p.f, p.s + s);
264 }
265
272 template <typename T, typename = typename std::enable_if<
273 std::is_integral<T>::value, T>::type>
274 inline uint128_t &operator+=(const T p) {
275 bool app = p + s < s;
276 this->f += app;
277 this->s += p;
278 return *this;
279 }
280
287 bool app = p.s + s < s;
288 f = f + app + p.f;
289 s = p.s + s;
290 return *this;
291 }
292
298 *this += 1;
299 return *this;
300 }
301
306 inline uint128_t operator++(int) {
307 ++*this;
308 return *this;
309 }
310
317 template <typename T, typename = typename std::enable_if<
318 std::is_integral<T>::value, T>::type>
319 inline uint128_t operator-(const T &p) {
320 bool app = p > s;
321 return uint128_t(f - app, s - p);
322 }
323
329 inline uint128_t operator-(const uint128_t &p) {
330 bool app = p.s > s;
331 return uint128_t(f - p.f - app, s - p.s);
332 }
333
338 inline uint128_t operator-() { return ~*this + uint128_t(1); }
339
345 *this -= 1;
346 return *this;
347 }
348
353 inline uint128_t operator--(int p) {
354 --*this;
355 return *this;
356 }
357
364 template <typename T, typename = typename std::enable_if<
365 std::is_integral<T>::value, T>::type>
366 uint128_t &operator-=(const T &p) {
367 bool app = p > s;
368 f -= app;
369 s -= p;
370 return *this;
371 }
372
379 bool app = p.s > s;
380 f = f - p.f - app;
381 s = s - p.s;
382 return *this;
383 }
384
391 template <typename T, typename = typename std::enable_if<
392 std::is_integral<T>::value, T>::type>
393 inline uint128_t operator*(const T p) {
394 return *this * uint128_t(p);
395 }
396
403 uint64_t f_first = s >> 32, f_second = s & 0xFFFFFFFF,
404 s_first = p.s >> 32, s_second = p.s & 0xFFFFFFFF;
405 uint64_t fi = f_first * s_first, se = f_first * s_second,
406 th = s_first * f_second, fo = s_second * f_second;
407 uint64_t tmp = ((se & 0xFFFFFFFF) << 32), tmp2 = (th & 0xFFFFFFFF)
408 << 32;
409 int cc = (tmp + tmp2 < tmp);
410 tmp += tmp2;
411 cc += (tmp + fo < tmp);
412 uint64_t carry = fi + (se >> 32) + (th >> 32);
413 return uint128_t(this->f * p.s + this->s * p.f + carry + cc, tmp + fo);
414 }
415
422 template <typename T, typename = typename std::enable_if<
423 std::is_integral<T>::value, T>::type>
424 inline uint128_t &operator*=(const T p) {
425 *this *= uint128_t(p);
426 return *this;
427 }
428
435 uint64_t f_first = s >> 32, f_second = s & 0xFFFFFFFF,
436 s_first = p.s >> 32, s_second = p.s & 0xFFFFFFFF;
437 uint64_t fi = f_first * s_first, se = f_first * s_second,
438 th = s_first * f_second, fo = s_second * f_second;
439 uint64_t tmp = (se << 32), tmp2 = (th << 32);
440 int cc = (tmp + tmp2 < tmp);
441 tmp += tmp2;
442 cc += (tmp + fo < tmp);
443 uint64_t carry = fi + (se >> 32) + (th >> 32);
444 f = this->f * p.s + this->s * p.f + carry + cc;
445 s = tmp + fo;
446 return *this;
447 }
448
455 std::pair<uint128_t, uint128_t> divide(const uint128_t &p) {
456 if (*this < p) { // if this is less than divisor
457 return {uint128_t(0), *this};
458 } else if (*this == p) { // if this is equal to divisor
459 return {uint128_t(1), uint128_t(0)};
460 }
461 uint128_t tmp = p, tmp2 = *this;
462 uint16_t left = tmp._lez() - _lez();
463 tmp <<= left;
464 uint128_t quotient(0);
465 uint128_t zero(0);
466 while (tmp2 >= p) {
467 uint16_t shf = tmp2._lez() - tmp._lez();
468 if (shf) {
469 tmp >>= shf;
470 quotient <<= shf;
471 left -= shf;
472 }
473 if (tmp2 < tmp) {
474 tmp >>= 1;
475 quotient <<= 1;
476 --left;
477 }
478 tmp2 -= tmp;
479 ++quotient;
480 }
481 return {quotient << left, tmp2};
482 }
483
489 inline uint128_t operator/(const uint128_t &p) { return divide(p).first; }
490
497 template <typename T, typename = typename std::enable_if<
498 std::is_integral<T>::value, T>::type>
499 inline uint128_t operator/(const T p) {
500 uint128_t tmp = *this;
501 tmp /= uint128_t(0, p);
502 return tmp;
503 }
504
510 inline uint128_t &operator/=(const uint128_t &p) {
511 *this = divide(p).first;
512 return *this;
513 }
514
521 template <typename T, typename = typename std::enable_if<
522 std::is_integral<T>::value, T>::type>
523 inline uint128_t &operator/=(const T p) {
524 *this /= uint128_t(0, p);
525 return *this;
526 }
527
533 inline uint128_t operator%(const uint128_t &p) { return divide(p).second; }
534
541 template <typename T, typename = typename std::enable_if<
542 std::is_integral<T>::value, T>::type>
543 inline uint128_t operator%(const T &p) {
544 return *this % uint128_t(p);
545 }
546
552 inline uint128_t &operator%=(const uint128_t &p) {
553 *this = divide(p).second;
554 return *this;
555 }
556
563 template <typename T, typename = typename std::enable_if<
564 std::is_integral<T>::value, T>::type>
565 inline uint128_t &operator%=(const T &p) {
566 *this %= uint128_t(p);
567 return *this;
568 }
569
575 inline bool operator<(const uint128_t &other) {
576 return f < other.f || (f == other.f && s < other.s);
577 }
578
584 inline bool operator<=(const uint128_t &other) {
585 return f < other.f || (f == other.f && s <= other.s);
586 }
587
593 inline bool operator>(const uint128_t &other) {
594 return f > other.f || (f == other.f && s > other.s);
595 }
596
602 inline bool operator>=(const uint128_t &other) {
603 return (f > other.f) || (f == other.f && s >= other.s);
604 }
605
611 inline bool operator==(const uint128_t &other) {
612 return f == other.f && s == other.s;
613 }
614
620 inline bool operator!=(const uint128_t &other) {
621 return f != other.f || s != other.s;
622 }
623
628 inline bool operator!() { return !f && !s; }
629
635 inline bool operator&&(const uint128_t &b) {
636 return (s || f) && (b.s || b.f);
637 }
638
644 inline bool operator||(const uint128_t &b) {
645 return (s || f) || (b.s || b.f);
646 }
647
652 inline bool operator()() { return s || f; }
653
660 template <typename T, typename = typename std::enable_if<
661 std::is_integral<T>::value, T>::type>
662 inline bool operator<(const T other) {
663 return *this < uint128_t(other);
664 }
665
672 template <typename T, typename = typename std::enable_if<
673 std::is_integral<T>::value, T>::type>
674 inline bool operator<=(const T other) {
675 return *this <= uint128_t(other);
676 }
677
684 template <typename T, typename = typename std::enable_if<
685 std::is_integral<T>::value, T>::type>
686 inline bool operator>(const T other) {
687 return *this > uint128_t(other);
688 }
689
696 template <typename T, typename = typename std::enable_if<
697 std::is_integral<T>::value, T>::type>
698 inline bool operator>=(const T other) {
699 return *this >= uint128_t(other);
700 }
701
708 template <typename T, typename = typename std::enable_if<
709 std::is_integral<T>::value, T>::type>
710 inline bool operator==(const T other) {
711 return *this == uint128_t(other);
712 }
713
720 template <typename T, typename = typename std::enable_if<
721 std::is_integral<T>::value, T>::type>
722 inline bool operator!=(const T other) {
723 return *this != uint128_t(other);
724 }
725
732 template <typename T, typename = typename std::enable_if<
733 std::is_integral<T>::value, T>::type>
734 inline bool operator&&(const T b) {
735 return (f || s) && b;
736 }
737
745 template <typename T, typename = typename std::enable_if<
746 std::is_integral<T>::value, T>::type>
747 inline bool operator||(const T b) {
748 return (f || s) || b;
749 }
750
755 uint128_t operator~() { return uint128_t(~this->f, ~this->s); }
756
763 template <typename T, typename = typename std::enable_if<
764 std::is_integral<T>::value, T>::type>
766 if (!p) {
767 return uint128_t(f, s);
768 } else if (p >= 64 && p <= 128) {
769 return uint128_t((this->s << (p - 64)), 0);
770 } else if (p < 64 && p > 0) {
771 return uint128_t((this->f << p) + ((this->s >> (64 - p))),
772 this->s << p);
773 }
774 return uint128_t(0);
775 }
776
783 template <typename T, typename = typename std::enable_if<
784 std::is_integral<T>::value, T>::type>
785 uint128_t &operator<<=(const T p) {
786 if (p) {
787 if (p >= 64 && p <= 128) {
788 this->f = (this->s << (p - 64));
789 this->s = 0;
790 } else {
791 f = ((this->f << p) + (this->s >> (64 - p)));
792 s = (this->s << p);
793 }
794 }
795 return *this;
796 }
797
804 template <typename T, typename = typename std::enable_if<
805 std::is_integral<T>::value, T>::type>
807 if (!p) {
808 return uint128_t(this->f, this->s);
809 } else if (p >= 64 && p <= 128) {
810 return uint128_t(0, (this->f >> (p - 64)));
811 } else if (p < 64 && p > 0) {
812 return uint128_t((this->f >> p),
813 (this->s >> p) + (this->f << (64 - p)));
814 }
815 return uint128_t(0);
816 }
817
824 template <typename T, typename = typename std::enable_if<
825 std::is_integral<T>::value, T>::type>
826 uint128_t &operator>>=(const T p) {
827 if (p) {
828 if (p >= 64) {
829 f = 0;
830 s = (this->f >> (p - 64));
831 } else {
832 s = (this->s >> p) + (this->f << (64 - p));
833 f = (this->f >> p);
834 }
835 }
836 return *this;
837 }
838
844 inline uint128_t operator&(const uint128_t &p) {
845 return uint128_t(this->f & p.f, this->s & p.s);
846 }
847
854 template <typename T, typename = typename std::enable_if<
855 std::is_integral<T>::value, T>::type>
856 uint128_t operator&(const T p) {
857 uint128_t tmp = *this;
858 return tmp & uint128_t(p);
859 }
860
867 this->f &= p.f;
868 this->s &= p.s;
869 return *this;
870 }
871
878 template <typename T, typename = typename std::enable_if<
879 std::is_integral<T>::value, T>::type>
880 uint128_t &operator&=(const T p) {
881 *this &= uint128_t(p);
882 return *this;
883 }
884
891 template <typename T, typename = typename std::enable_if<
892 std::is_integral<T>::value, T>::type>
893 inline uint128_t operator|(const T p) {
894 return uint128_t(p | s);
895 }
896
902 inline uint128_t operator|(const uint128_t &p) {
903 return uint128_t(this->f | p.f, this->s | p.s);
904 }
905
912 f |= p.f;
913 s |= p.s;
914 return *this;
915 }
916
923 template <typename T, typename = typename std::enable_if<
924 std::is_integral<T>::value, T>::type>
925 inline uint128_t &operator|=(const T p) {
926 s |= p.s;
927 return *this;
928 }
929
936 template <typename T, typename = typename std::enable_if<
937 std::is_integral<T>::value, T>::type>
938 inline uint128_t operator^(const T p) {
939 return uint128_t(this->f, this->s ^ p);
940 }
941
947 inline uint128_t operator^(const uint128_t &p) {
948 return uint128_t(this->f ^ p.f, this->s ^ p.s);
949 }
950
957 f ^= p.f;
958 s ^= p.s;
959 return *this;
960 }
961
968 template <typename T, typename = typename std::enable_if<
969 std::is_integral<T>::value, T>::type>
970 inline uint128_t &operator^=(const T &p) {
971 s ^= p;
972 return *this;
973 }
974
984 friend std::ostream &operator<<(std::ostream &op, const uint128_t &p) {
985 if (!p.f) {
986 op << p.s;
987 } else {
988 std::string out = "0", p_2 = "1";
989 for (int i = 0; i < 64; ++i) {
990 if (p.s & (1LL << i)) {
991 out = add(out, p_2);
992 }
993 p_2 = add(p_2, p_2);
994 }
995 for (int i = 0; i < 64; ++i) {
996 if (p.f & (1LL << i)) {
997 out = add(out, p_2);
998 }
999 p_2 = add(p_2, p_2);
1000 }
1001 op << out;
1002 }
1003 return op;
1004 }
1005};
1006
1007// Arithmetic operators
1008template <typename T, typename = typename std::enable_if<
1009 std::is_integral<T>::value, T>::type>
1010inline uint128_t operator+(const T &p, const uint128_t &q) {
1011 return uint128_t(p) + q;
1012}
1013
1014template <typename T, typename = typename std::enable_if<
1015 std::is_integral<T>::value, T>::type>
1016inline uint128_t operator-(const T p, const uint128_t &q) {
1017 return uint128_t(p) - q;
1018}
1019
1020template <typename T, typename = typename std::enable_if<
1021 std::is_integral<T>::value, T>::type>
1022inline uint128_t operator*(const T p, const uint128_t &q) {
1023 return uint128_t(p) * q;
1024}
1025
1026template <typename T, typename = typename std::enable_if<
1027 std::is_integral<T>::value, T>::type>
1028inline uint128_t operator/(const T p, const uint128_t &q) {
1029 return uint128_t(p) / q;
1030}
1031
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
1038// Bitwise operators
1039template <typename T, typename = typename std::enable_if<
1040 std::is_integral<T>::value, T>::type>
1041inline uint128_t operator&(const T &p, const uint128_t &q) {
1042 return uint128_t(p) & q;
1043}
1044
1045template <typename T, typename = typename std::enable_if<
1046 std::is_integral<T>::value, T>::type>
1047inline uint128_t operator|(const T p, const uint128_t &q) {
1048 return uint128_t(p) | q;
1049}
1050
1051template <typename T, typename = typename std::enable_if<
1052 std::is_integral<T>::value, T>::type>
1053inline uint128_t operator^(const T p, const uint128_t &q) {
1054 return uint128_t(p) ^ q;
1055}
1056
1057// Boolean operators
1058template <typename T, typename = typename std::enable_if<
1059 std::is_integral<T>::value, T>::type>
1060inline bool operator&&(const T p, const uint128_t &q) {
1061 return uint128_t(p) && q;
1062}
1063
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
1070// Comparison operators
1071template <typename T, typename = typename std::enable_if<
1072 std::is_integral<T>::value, T>::type>
1073inline bool operator==(const T p, const uint128_t &q) {
1074 return uint128_t(p) == q;
1075}
1076
1077template <typename T, typename = typename std::enable_if<
1078 std::is_integral<T>::value, T>::type>
1079inline bool operator!=(const T p, const uint128_t &q) {
1080 return uint128_t(p) != q;
1081}
1082
1083template <typename T, typename = typename std::enable_if<
1084 std::is_integral<T>::value, T>::type>
1085inline bool operator<(const T p, const uint128_t &q) {
1086 return uint128_t(p) < q;
1087}
1088
1089template <typename T, typename = typename std::enable_if<
1090 std::is_integral<T>::value, T>::type>
1091inline bool operator<=(const T p, const uint128_t &q) {
1092 return uint128_t(p) <= q;
1093}
1094
1095template <typename T, typename = typename std::enable_if<
1096 std::is_integral<T>::value, T>::type>
1097inline bool operator>(const T p, const uint128_t &q) {
1098 return uint128_t(p) > q;
1099}
1100
1101template <typename T, typename = typename std::enable_if<
1102 std::is_integral<T>::value, T>::type>
1103inline bool operator>=(const T p, const uint128_t &q) {
1104 return uint128_t(p) >= q;
1105}
1106
1107#endif // CIPHERS_UINT128_T_HPP_
class for 128-bit unsigned integer
Definition uint128_t.hpp:60
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--(int p)
operator – (post-decrement)
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
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:70
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.
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:38