20 #include "ns3/core-config.h"
22 #if !defined(INT64X64_128_H) && defined (INT64X64_USE_128) && !defined(PYTHON_SCAN)
23 #define INT64X64_128_H
28 #if defined(HAVE___UINT128_T) && !defined(HAVE_UINT128_T)
29 typedef __uint128_t uint128_t;
30 typedef __int128_t int128_t;
48 static const uint128_t HP128_MASK_HI_BIT = (((int128_t)1)<<127);
50 static const uint64_t HP_MASK_LO = 0xffffffffffffffffULL;
52 static const uint64_t HP_MASK_HI = ~HP_MASK_LO;
66 #define HP_MAX_64 (std::pow (2.0L, 64))
83 static const enum impl_type implementation = int128_impl;
101 const bool negative = value < 0;
102 const long double v = negative ? -value : value;
105 long double flo = std::modf (v, &fhi);
114 const long double round = 0.5;
115 flo = flo * HP_MAX_64 + round;
117 const uint64_t lo = flo;
118 if (flo >= HP_MAX_64)
125 _v = negative ? -_v : _v;
160 inline int64x64_t (
const unsigned long long int v)
173 explicit inline int64x64_t (
const int64_t hi,
const uint64_t lo)
175 _v = (int128_t)hi << 64;
203 inline double GetDouble (
void)
const
205 const bool negative = _v < 0;
206 const uint128_t value = negative ? -_v : _v;
207 const long double fhi = value >> 64;
208 const long double flo = (value & HP_MASK_LO) / HP_MAX_64;
209 long double retval = fhi;
211 retval = negative ? -retval : retval;
219 inline int64_t GetHigh (
void)
const
221 const int128_t retval = _v >> 64;
229 inline uint64_t GetLow (
void)
const
231 const uint128_t retval = _v & HP_MASK_LO;
311 static uint128_t Umul (
const uint128_t a,
const uint128_t b);
319 static uint128_t Udiv (
const uint128_t a,
const uint128_t b);
329 static uint128_t UmulByInvert (
const uint128_t a,
const uint128_t b);
350 return lhs._v == rhs._v;
358 return lhs._v < rhs._v;
366 return lhs._v > rhs._v;
High precision numerical type, implementing Q64.64 fixed precision.
bool operator>(const Time &lhs, const Time &rhs)
Time & operator+=(Time &lhs, const Time &rhs)
TracedValue< T > & operator/=(TracedValue< T > &lhs, const U &rhs)
Operator assignment for TracedValue.
int64x64_t operator+(const int64x64_t &lhs, const int64x64_t &rhs)
Addition operator.
TracedValue< T > operator!(const TracedValue< T > &lhs)
Unary arithmetic operator for TracedValue.
int64x64_t operator-(const int64x64_t &lhs, const int64x64_t &rhs)
Subtraction operator.
Time & operator-=(Time &lhs, const Time &rhs)
bool operator==(const BleAccessAddress &a, const BleAccessAddress &b)
TracedValue< T > & operator*=(TracedValue< T > &lhs, const U &rhs)
Operator assignment for TracedValue.
bool operator<(const BleAccessAddress &a, const BleAccessAddress &b)