20#include "ns3/core-config.h"
22#if !defined(INT64X64_128_H) && defined (INT64X64_USE_128) && !defined(PYTHON_SCAN)
32#if defined(HAVE___UINT128_T) && !defined(HAVE_UINT128_T)
38typedef __uint128_t uint128_t;
39typedef __int128_t int128_t;
58 static const uint128_t HP128_MASK_HI_BIT = (((int128_t)1) << 127);
60 static const uint64_t
HP_MASK_LO = 0xffffffffffffffffULL;
62 static const uint64_t HP_MASK_HI = ~HP_MASK_LO;
76#define HP_MAX_64 (std::pow (2.0L, 64))
116 const bool negative = value < 0;
117 const long double v = negative ? -value : value;
120 long double flo = std::modf (v, &fhi);
129 const long double round = 0.5;
132 const uint64_t lo = flo;
178 inline int64x64_t (
const unsigned long long int v)
194 explicit inline int64x64_t (
const int64_t hi,
const uint64_t lo)
196 _v = (int128_t)hi << 64;
221 inline explicit operator bool ()
const
233 const bool negative =
_v < 0;
234 const uint128_t value = negative ? -
_v :
_v;
235 const long double fhi = value >> 64;
237 long double retval = fhi;
239 retval = negative ? -retval : retval;
247 inline int64_t
GetHigh (
void)
const
249 const int128_t retval =
_v >> 64;
257 inline uint64_t
GetLow (
void)
const
268 int64_t
GetInt (
void)
const
270 const bool negative =
_v < 0;
271 const uint128_t value = negative ? -
_v :
_v;
272 int64_t retval = value >> 64;
273 retval = negative ? - retval : retval;
283 int64_t
Round (
void)
const
285 const bool negative =
_v < 0;
286 int64x64_t value = (negative ? -(*this) : *
this);
289 int64_t retval = value.GetHigh ();
290 retval = negative ? - retval : retval;
411 static uint128_t
Umul (
const uint128_t a,
const uint128_t b);
419 static uint128_t
Udiv (
const uint128_t a,
const uint128_t b);
429 static uint128_t
UmulByInvert (
const uint128_t a,
const uint128_t b);
friend bool operator==(const int64x64_t &lhs, const int64x64_t &rhs)
Arithmetic operator.
static const uint64_t HP_MASK_LO
Mask for fraction part.
static cairo_uint128_t Umul(const cairo_uint128_t a, const cairo_uint128_t b)
Unsigned multiplication of Q64.64 values.
int64_t GetInt(void) const
Truncate to an integer.
impl_type
Type tag for the underlying implementation.
@ int128_impl
Native int128_t implementation.
@ ld_impl
long double implementation
@ cairo_impl
cairo wideint implementation
static cairo_uint128_t UmulByInvert(const cairo_uint128_t a, const cairo_uint128_t b)
Unsigned multiplication of Q64.64 and Q0.128 values.
friend int64x64_t & operator-=(int64x64_t &lhs, const int64x64_t &rhs)
Arithmetic operator.
friend int64x64_t operator+(const int64x64_t &lhs)
Unary operator.
int64_t Round(void) const
Round to the nearest int.
void Mul(const int64x64_t &o)
Implement *=.
void MulByInvert(const int64x64_t &o)
Multiply this value by a Q0.128 value, presumably representing an inverse, completing a division oper...
static cairo_uint128_t Udiv(const cairo_uint128_t a, const cairo_uint128_t b)
Unsigned division of Q64.64 values.
friend bool operator<(const int64x64_t &lhs, const int64x64_t &rhs)
Arithmetic operator.
static enum impl_type implementation
Type tag for this implementation.
friend int64x64_t operator!(const int64x64_t &lhs)
Unary operator.
cairo_int128_t _v
The Q64.64 value.
friend int64x64_t & operator*=(int64x64_t &lhs, const int64x64_t &rhs)
Arithmetic operator.
int64_t GetHigh(void) const
Get the integer portion.
void Div(const int64x64_t &o)
Implement /=.
uint64_t GetLow(void) const
Get the fractional portion of this value, unscaled.
friend int64x64_t & operator+=(int64x64_t &lhs, const int64x64_t &rhs)
Arithmetic operator.
int64x64_t & operator=(const int64x64_t &o)
Assignment.
friend bool operator>(const int64x64_t &lhs, const int64x64_t &rhs)
Arithmetic operator.
double GetDouble(void) const
Get this value as a double.
friend int64x64_t operator-(const int64x64_t &lhs)
Unary operator.
static int64x64_t Invert(const uint64_t v)
Compute the inverse of an integer value.
friend int64x64_t & operator/=(int64x64_t &lhs, const int64x64_t &rhs)
Arithmetic operator.
int64x64_t()
Default constructor.
#define HP_MAX_64
Floating point value of HP_MASK_LO + 1 We really want:
Every class exported by the ns3 library is enclosed in the ns3 namespace.