#include <Int128.h>
|
| | Int128 (const uint64_t &a, const int64_t &b) |
| |
◆ Int128() [1/11]
◆ Int128() [2/11]
| inet::Int128::Int128 |
( |
const Int128 & |
a | ) |
|
|
inline |
62 :
lo(a.lo),
hi(a.hi) {}
◆ Int128() [3/11]
| inet::Int128::Int128 |
( |
const uint32_t & |
a | ) |
|
|
inline |
◆ Int128() [4/11]
| inet::Int128::Int128 |
( |
const int32_t & |
a | ) |
|
|
inline |
◆ Int128() [5/11]
| inet::Int128::Int128 |
( |
const uint64_t & |
a | ) |
|
|
inline |
◆ Int128() [6/11]
| inet::Int128::Int128 |
( |
const int64_t & |
a | ) |
|
|
inline |
◆ Int128() [7/11]
| inet::Int128::Int128 |
( |
const float |
a | ) |
|
110 :
lo((uint64_t)fmodf(a, 18446744073709551616.0f)),
111 hi((int64_t)(a / 18446744073709551616.0f)) {}
◆ Int128() [8/11]
| inet::Int128::Int128 |
( |
const double & |
a | ) |
|
114 :
lo((uint64_t)fmod(a, 18446744073709551616.0)),
115 hi((int64_t)(a / 18446744073709551616.0)) {}
◆ Int128() [9/11]
| inet::Int128::Int128 |
( |
const long double & |
a | ) |
|
118 :
lo((uint64_t)fmodl(a, 18446744073709551616.0l)),
119 hi((int64_t)(a / 18446744073709551616.0l)) {}
◆ Int128() [10/11]
| inet::Int128::Int128 |
( |
const char * |
sz | ) |
|
|
inline |
◆ Int128() [11/11]
| inet::Int128::Int128 |
( |
const uint64_t & |
a, |
|
|
const int64_t & |
b |
|
) |
| |
|
inlineprivate |
◆ bit() [1/2]
| bool inet::Int128::bit |
( |
unsigned int |
n | ) |
const |
295 return lo & (1ull << n);
297 return hi & (1ull << (n - 64));
Referenced by div().
◆ bit() [2/2]
| void inet::Int128::bit |
( |
unsigned int |
n, |
|
|
bool |
val |
|
) |
| |
309 hi |= (1ull << (n - 64));
315 hi &= ~(1ull << (n - 64));
◆ div()
240 return 1u / (
unsigned int)divisor.lo;
244 Int128 ds = (divisor < 0) ? -divisor : divisor;
245 Int128 dd = (*
this < 0) ? -*
this : *
this;
257 unsigned int b = 127;
280 if ((divisor < 0) ^ (*
this < 0))
Referenced by toString().
◆ operator double()
| inet::Int128::operator double |
( |
| ) |
|
|
inline |
◆ operator int()
| inet::Int128::operator int |
( |
| ) |
|
|
inline |
◆ operator!()
| bool inet::Int128::operator! |
( |
| ) |
const |
|
inline |
104 {
return !(
hi ||
lo); }
◆ operator%=()
◆ operator&=()
121 {
hi &=
b.hi;
lo &=
b.lo;
return *
this; }
◆ operator*=()
227 for (
unsigned int i = 0; i < 128; ++i) {
◆ operator+()
| const Int128& inet::Int128::operator+ |
( |
| ) |
const |
|
inline |
◆ operator++() [1/2]
| Int128 & inet::Int128::operator++ |
( |
| ) |
|
◆ operator++() [2/2]
| Int128 inet::Int128::operator++ |
( |
int |
| ) |
|
◆ operator+=()
204 uint64_t old_lo =
lo;
◆ operator-()
| Int128 inet::Int128::operator- |
( |
| ) |
const |
◆ operator--() [1/2]
| Int128 & inet::Int128::operator-- |
( |
| ) |
|
◆ operator--() [2/2]
| Int128 inet::Int128::operator-- |
( |
int |
| ) |
|
◆ operator-=()
130 return *
this += (-
b);
◆ operator/=()
136 *
this = this->
div(
b, dummy);
◆ operator<<=()
| Int128 & inet::Int128::operator<<= |
( |
unsigned int |
n | ) |
|
368 uint64_t mask = ~((1ull << (64 - n)) - 1);
371 hi |= (
lo & mask) >> (64 - n);
◆ operator=() [1/9]
| Int128& inet::Int128::operator= |
( |
const char * |
sz | ) |
|
|
inline |
92 {
set(sz);
return *
this; }
◆ operator=() [2/9]
| Int128 & inet::Int128::operator= |
( |
const double & |
a | ) |
|
142 lo = ((uint64_t)fmod(a, 18446744073709551616.0));
143 hi = ((int64_t)(a / 18446744073709551616.0));
◆ operator=() [3/9]
| Int128 & inet::Int128::operator= |
( |
const float & |
a | ) |
|
135 lo = ((uint64_t)fmodf(a, 18446744073709551616.0f));
136 hi = ((int64_t)(a / 18446744073709551616.0f));
◆ operator=() [4/9]
85 {
lo = other.lo;
hi = other.hi;
return *
this; }
◆ operator=() [5/9]
| Int128& inet::Int128::operator= |
( |
const int32_t & |
a | ) |
|
|
inline |
86 {
lo = a;
hi = 0;
return *
this; }
◆ operator=() [6/9]
| Int128& inet::Int128::operator= |
( |
const int64_t & |
a | ) |
|
|
inline |
89 {
lo = a;
hi = 0;
return *
this; }
◆ operator=() [7/9]
| Int128 & inet::Int128::operator= |
( |
const long double & |
a | ) |
|
149 lo = ((uint64_t)fmodl(a, 18446744073709551616.0l));
150 hi = ((int64_t)(a / 18446744073709551616.0l));
◆ operator=() [8/9]
| Int128& inet::Int128::operator= |
( |
const uint32_t & |
a | ) |
|
|
inline |
87 {
lo = a;
hi = 0;
return *
this; }
◆ operator=() [9/9]
| Int128& inet::Int128::operator= |
( |
const uint64_t & |
a | ) |
|
|
inline |
90 {
lo = a;
hi = 0;
return *
this; }
◆ operator>>=()
| Int128 & inet::Int128::operator>>= |
( |
unsigned int |
n | ) |
|
322 hi = (
hi < 0) ? -1ll : 0ll;
329 hi = (
hi < 0) ? -1ll : 0ll;
338 uint64_t mask = (1ull << n) - 1;
341 lo |= (
hi & mask) << (64 - n);
◆ operator^=()
122 {
hi ^=
b.hi;
lo ^=
b.lo;
return *
this; }
◆ operator|=()
120 {
hi |=
b.hi;
lo |=
b.lo;
return *
this; }
◆ operator~()
| Int128 inet::Int128::operator~ |
( |
| ) |
const |
|
inline |
◆ set()
| void inet::Int128::set |
( |
const char * |
sz | ) |
|
90 for (; i < strlen(sz); ++i) {
92 if (sz[i] >=
'0' && sz[i] <=
'9' && sz[i] <
'0' + (
int)radix)
94 else if (sz[i] >=
'a' && sz[i] <=
'a' + (
int)radix - 10)
96 else if (sz[i] >=
'A' && sz[i] <=
'A' + (
int)radix - 10)
106 *
this =
Int128(0) - *
this;
◆ toDouble()
| double inet::Int128::toDouble |
( |
| ) |
const |
129 return (
double)
hi * 18446744073709551616.0
◆ toFloat()
| float inet::Int128::toFloat |
( |
| ) |
const |
123 return (
float)
hi * 18446744073709551616.0f
◆ toInt()
| int inet::Int128::toInt |
( |
| ) |
const |
|
inline |
◆ toInt64()
| int64_t inet::Int128::toInt64 |
( |
| ) |
const |
|
inline |
148 {
return (int64_t)
lo; }
◆ toLongDouble()
| long double inet::Int128::toLongDouble |
( |
| ) |
const |
156 return (
long double)
hi * 18446744073709551616.0l
◆ toString()
| const char * inet::Int128::toString |
( |
uint32_t |
radix = 10 | ) |
const |
41 if (radix < 2 || radix > 37)
42 return "(invalid radix)";
48 Int128 ii = (*
this < 0) ? -*
this : *
this;
54 unsigned int c = r.toInt();
55 sz[--i] =
c + ((
c > 9) ?
'A' - 10 :
'0');
◆ operator&&
183 return (a.hi || a.lo) && (
b.hi ||
b.lo);
◆ operator<
384 return (int64_t)a.lo < (int64_t)
b.lo;
◆ operator==
178 return a.hi ==
b.hi && a.lo ==
b.lo;
◆ operator||
188 return (a.hi || a.lo) || (
b.hi ||
b.lo);
◆ hi
Referenced by bit(), inet::operator&&(), operator*=(), operator++(), operator+=(), operator-(), operator--(), inet::operator<(), operator<<=(), operator=(), inet::operator==(), operator>>=(), inet::operator||(), set(), toDouble(), toFloat(), and toLongDouble().
◆ INT128_MAX
| const Int128 inet::Int128::INT128_MAX |
|
static |
◆ INT128_MIN
| const Int128 inet::Int128::INT128_MIN |
|
static |
◆ lo
| uint64_t inet::Int128::lo |
|
private |
Referenced by bit(), div(), inet::operator&&(), operator*=(), operator++(), operator+=(), operator-(), operator--(), inet::operator<(), operator<<=(), operator=(), inet::operator==(), operator>>=(), inet::operator||(), set(), toDouble(), toFloat(), and toLongDouble().
The documentation for this class was generated from the following files: