15#ifndef CIPHERS_UINT256_T_HPP_ 
   16#define CIPHERS_UINT256_T_HPP_ 
   45        if (str.
size() > 1 && str[1] == 
'x') {
 
   46            for (
auto i = 2; i < str.
size(); ++i) {
 
   48                if (str[i] >= 
'0' && str[i] <= 
'9') {
 
   49                    *
this += (str[i] - 
'0');
 
   50                } 
else if (str[i] >= 
'A' && str[i] <= 
'F') {
 
   51                    *
this += (str[i] - 
'A' + 10);
 
   52                } 
else if (str[i] >= 
'a' && str[i] <= 
'f') {
 
   53                    *
this += (str[i] - 
'a' + 10);
 
  104        : f(
std::move(high)), s(
std::move(low)) {}
 
  111    uint256_t(
const uint64_t high, 
const uint64_t low) : f(high), s(low) {}
 
  127        return 128 + s.
_lez();
 
  139        return 128 + f.
_trz();
 
  146    inline explicit operator bool()
 const { 
return f || s; }
 
  155    inline explicit operator T()
 const {
 
  156        return static_cast<T
>(s);
 
  163    inline explicit operator uint128_t()
 const { 
return s; }
 
  221        bool app = s + p < s;
 
  231        bool app = (s + p.s < s);
 
  232        return {f + app + p.f, s + p.s};
 
  244        bool app = (p + s < s);
 
  256        bool app = (s + p.s < s);
 
  300        return {f - p.f - app, s - p.s};
 
  373            s_second(p.s.
lower());
 
  374        uint128_t fi = f_first * s_first, se = f_first * s_second,
 
  375                  th = s_first * f_second, fo = s_second * f_second;
 
  376        uint128_t tmp = se << 64, tmp2 = th << 64;
 
  377        int cc = (tmp + tmp2 < tmp);
 
  379        cc += (tmp + fo < tmp);
 
  380        return {f * p.s + s * p.f + fi + se.
upper() + th.upper() + cc,
 
  403            s_second(p.s.
lower());
 
  404        uint128_t fi = f_first * s_first, se = f_first * s_second,
 
  405                  th = s_first * f_second, fo = s_second * f_second;
 
  406        uint128_t tmp = se << 64, tmp2 = th << 64;
 
  407        int cc = (tmp + tmp2 < tmp);
 
  409        cc += (tmp + fo < tmp);
 
  410        f = f * p.s + s * p.f + fi + se.
upper() + th.upper() + cc;
 
  424        } 
else if (*
this == p) {  
 
  428        uint16_t left = tmp.
_lez() - 
_lez();
 
  433            uint16_t shf = tmp2._lez() - tmp.
_lez();
 
  447        return {quotient << left, tmp2};
 
  544        return f < other.f || (f == other.f && s < other.s);
 
  553        return f < other.f || (f == other.f && s <= other.s);
 
  562        return f > other.f || (f == other.f && s > other.s);
 
  571        return (f > other.f) || (f == other.f && s >= other.s);
 
  580        return f == other.f && s == other.s;
 
  589        return !((*this) == other);
 
  604        return (s || f) && (b.s || b.f);
 
  613        return (s || f) || (b.s || b.f);
 
  703        return (s || f) && (b);
 
  716        return (s || f) || (b);
 
  735            return {this->f, this->s};
 
  736        } 
else if (p >= 128) {
 
  739        return uint256_t((this->f << p) + (this->s >> (128 - p)),
 
  754                this->f = (this->s << (p - 128));
 
  757                f = ((this->s >> (128 - p)) + (this->f << p));
 
  774            return {this->f, this->s};
 
  775        } 
else if (p >= 128) {
 
  779                         (this->s >> p) + (this->f << (128 - p)));
 
  794                s = (this->f >> (p - 128));
 
  796                s = (this->s >> p) + (this->f << (128 - p));
 
  821        return {f & p.f, s & p.s};
 
  866        return {this->f | p.f, this->s | p.s};
 
  911        return {this->f ^ p.f, this->s ^ p.s};
 
  953            for (uint64_t i = 0; i < 128; ++i) {
 
  961            for (
int i = 0; i < 128; ++i) {
 
 1027inline bool operator&&(
const T p, 
const uint256_t &q) {
 
 1033inline bool operator||(
const T p, 
const uint256_t &q) {
 
 1052inline bool operator<(
const T p, 
const uint256_t &q) {
 
class for 128-bit unsigned integer
Definition: uint128_t.hpp:59
uint64_t upper() const
returns upper 64-bit integer part
Definition: uint128_t.hpp:207
uint32_t _trz()
Trailing zeroes in binary.
Definition: uint128_t.hpp:162
uint64_t lower() const
returns lower 64-bit integer part
Definition: uint128_t.hpp:201
uint32_t _lez()
Leading zeroes in binary.
Definition: uint128_t.hpp:139
class for 256-bit unsigned integer
Definition: uint256_t.hpp:33
uint256_t(uint128_t high, uint128_t low)
Parameterized constructor.
Definition: uint256_t.hpp:103
bool operator!()
operator ! for uint256_t
Definition: uint256_t.hpp:596
uint32_t _lez()
Leading zeroes in binary.
Definition: uint256_t.hpp:123
uint256_t(uint256_t &&num) noexcept
Move constructor.
Definition: uint256_t.hpp:95
uint256_t & operator<<=(const T &p)
operator <<= for uint256_t
Definition: uint256_t.hpp:751
bool operator<=(const uint256_t &other)
operator <= for uint256_t
Definition: uint256_t.hpp:552
uint256_t(const std::string &str)
Parameterized constructor.
Definition: uint256_t.hpp:81
bool operator<=(const T &other)
operator <= for other types
Definition: uint256_t.hpp:642
uint256_t operator+(const T &p)
operator + for uint256_t and other integer types.
Definition: uint256_t.hpp:220
uint256_t operator--(int p)
operator – (post-decrement)
Definition: uint256_t.hpp:322
uint256_t(const uint64_t high, const uint64_t low)
Parameterized constructor.
Definition: uint256_t.hpp:111
uint256_t & operator%=(const uint256_t &p)
operator %= for uint256_t
Definition: uint256_t.hpp:520
uint256_t operator|(const uint256_t &p)
operator | for uint256_t (bitwise operator)
Definition: uint256_t.hpp:865
bool operator&&(const T &b)
operator && for other types
Definition: uint256_t.hpp:702
uint256_t & operator&=(const uint256_t &p)
operator &= for uint256_t (bitwise operator)
Definition: uint256_t.hpp:829
uint256_t & operator^=(const T &p)
operator ^= for other types (bitwise operator)
Definition: uint256_t.hpp:933
~uint256_t()=default
Destructor for uint256_t.
uint256_t operator-()
operator - using twos complement
Definition: uint256_t.hpp:307
bool operator||(const uint256_t &b)
operator || for uint256_t
Definition: uint256_t.hpp:612
uint256_t(const uint256_t &num)=default
Copy constructor.
uint256_t & operator*=(const uint256_t &p)
operator *= for uint256_t and other integer types.
Definition: uint256_t.hpp:401
uint256_t operator>>(const T &p)
operator >> for uint256_t
Definition: uint256_t.hpp:772
uint256_t operator<<(const T &p)
operator << for uint256_t
Definition: uint256_t.hpp:733
bool operator||(const T &b)
operator || for other types
Definition: uint256_t.hpp:715
uint256_t & operator=(const uint256_t &p)=default
operator = for uint256_t
uint256_t operator/(const uint256_t &p)
operator / for uint256_t and other integer types.
Definition: uint256_t.hpp:469
uint256_t & operator+=(const T &p)
operator += for uint256_t and other integer types.
Definition: uint256_t.hpp:243
uint256_t & operator-=(const uint256_t &p)
operator -= for uint256_t
Definition: uint256_t.hpp:347
uint256_t & operator=(uint256_t &&p)=default
Move assignment operator.
uint256_t operator&(const T &p)
operator & for other types (bitwise operator)
Definition: uint256_t.hpp:811
uint256_t operator~()
operator ~ for uint256_t
Definition: uint256_t.hpp:723
uint256_t operator^(const uint256_t &p)
operator ^ for uint256_t (bitwise operator)
Definition: uint256_t.hpp:910
uint256_t & operator%=(const T &p)
operator %= for uint256_t
Definition: uint256_t.hpp:533
bool operator()()
operator () for uint256_t
Definition: uint256_t.hpp:620
uint256_t operator++(int)
post-increment operator
Definition: uint256_t.hpp:275
uint256_t operator%(const T &p)
operator % for uint256_t and other integer types.
Definition: uint256_t.hpp:509
std::pair< uint256_t, uint256_t > divide(const uint256_t &p)
divide function for uint256_t and other integer types.
Definition: uint256_t.hpp:421
uint256_t & operator=(const std::string &p)
operator = for type string
Definition: uint256_t.hpp:202
uint256_t operator-(const T &p)
operator - for uint256_t and other integer types.
Definition: uint256_t.hpp:288
bool operator!=(const T &other)
operator != for other types
Definition: uint256_t.hpp:690
bool operator==(const uint256_t &other)
operator == for uint256_t
Definition: uint256_t.hpp:579
friend std::ostream & operator<<(std::ostream &op, uint256_t p)
operator << for printing uint256_t integer
Definition: uint256_t.hpp:947
bool operator==(const T &other)
operator == for other types
Definition: uint256_t.hpp:678
uint256_t operator&(const uint256_t &p)
operator & for uint256_t (bitwise operator)
Definition: uint256_t.hpp:820
uint32_t _trz()
Trailing zeroes in binary.
Definition: uint256_t.hpp:135
uint256_t & operator--()
operator – (pre-decrement)
Definition: uint256_t.hpp:313
bool operator&&(const uint256_t &b)
operator && for uint256_t
Definition: uint256_t.hpp:603
uint256_t & operator|=(const uint256_t &p)
operator |= for uint256_t (bitwise operator)
Definition: uint256_t.hpp:887
uint128_t lower() const
returns lower 128-bit integer part
Definition: uint256_t.hpp:169
uint256_t operator*(const uint256_t &p)
operator * for uint256_t and other integer types.
Definition: uint256_t.hpp:371
uint256_t operator*(const T &p)
operator * for uint256_t and other integer types.
Definition: uint256_t.hpp:362
bool operator!=(const uint256_t &other)
operator != for uint256_t
Definition: uint256_t.hpp:588
uint256_t operator-(const uint256_t &p)
operator - for uint256_t
Definition: uint256_t.hpp:298
uint256_t & operator/=(const T &p)
operator /= for uint256_t and other integer types.
Definition: uint256_t.hpp:489
uint256_t & operator/=(const uint256_t &p)
operator /= for uint256_t
Definition: uint256_t.hpp:476
bool operator<(const T &other)
operator < for other types
Definition: uint256_t.hpp:630
uint256_t & operator+=(const uint256_t &p)
operator += for uint256_t
Definition: uint256_t.hpp:255
uint256_t & operator^=(const uint256_t &p)
operator ^= for uint256_t (bitwise operator)
Definition: uint256_t.hpp:919
uint256_t operator/(const T &p)
operator / for uint256_t and other integer types.
Definition: uint256_t.hpp:458
bool operator>(const uint256_t &other)
operator > for uint256_t
Definition: uint256_t.hpp:561
uint256_t operator^(const T &p)
operator ^ for other types (bitwise operator)
Definition: uint256_t.hpp:901
uint256_t operator-=(const T p)
operator -= for uint256_t and other integer types.
Definition: uint256_t.hpp:335
uint256_t operator|(const T &p)
operator | for other types (bitwise operator)
Definition: uint256_t.hpp:856
uint256_t operator%(const uint256_t &p)
operator % for uint256_t
Definition: uint256_t.hpp:499
bool operator>(const T &other)
operator > for other types
Definition: uint256_t.hpp:654
uint256_t & operator>>=(const T &p)
operator >>= for uint256_t
Definition: uint256_t.hpp:790
uint256_t & operator=(const T &p)
operator = for other types
Definition: uint256_t.hpp:192
bool operator>=(const uint256_t &other)
operator >= for uint256_t
Definition: uint256_t.hpp:570
uint128_t upper() const
returns upper 128-bit integer part
Definition: uint256_t.hpp:175
uint256_t(T low)
Parameterized constructor.
Definition: uint256_t.hpp:75
uint256_t & operator|=(const T &p)
operator |= for other types (bitwise operator)
Definition: uint256_t.hpp:877
uint256_t & operator++()
pre-increment operator
Definition: uint256_t.hpp:266
uint256_t operator+(const uint256_t &p)
operator + for uint256_t and other integer types.
Definition: uint256_t.hpp:230
uint256_t & operator*=(const T &p)
operator *= for uint256_t and other integer types.
Definition: uint256_t.hpp:392
uint256_t & operator&=(const T p)
operator &= for other types (bitwise operator)
Definition: uint256_t.hpp:843
bool operator<(const uint256_t &other)
operator < for uint256_t
Definition: uint256_t.hpp:543
void __get_integer_from_string(const std::string &str)
First and second half of 256 bit number.
Definition: uint256_t.hpp:43
bool operator>=(const T &other)
operator >= for other types
Definition: uint256_t.hpp:666
bool operator==(const Complex &a, const Complex &b)
Operator overload of '==' on Complex class. Logical Equal overload for our Complex class.
Definition: complex_numbers.cpp:175
std::vector< T > operator+(std::vector< T > const &A, std::vector< T > const &B)
Definition: ordinary_least_squares_regressor.cpp:204
std::vector< T > operator-(std::vector< T > const &A, std::vector< T > const &B)
Definition: ordinary_least_squares_regressor.cpp:183
std::vector< float > operator/(std::vector< T > const &A, float const scalar)
Definition: ordinary_least_squares_regressor.cpp:174
std::string add(const std::string &first, const std::string &second)
Adding two string.
Definition: uint128_t.hpp:37