20 #include "ns3/core-config.h"
21 #if !defined(INT64X64_DOUBLE_H) && (defined (INT64X64_USE_DOUBLE) || defined(PYTHON_SCAN))
22 #define INT64X64_DOUBLE_H
44 static const uint64_t
HP_MASK_LO = 0xffffffffffffffffULL;
57 #define HP_MAX_64 (std::pow (2.0L, 64))
108 :
_v (static_cast<double> (v))
117 :
_v (static_cast<double> (v))
128 const bool negative = hi < 0;
129 const long double hild =
static_cast<long double> (hi);
130 const long double fhi = negative ? -hild : hild;
132 _v = negative ? -fhi : fhi;
175 const bool negative =
_v < 0;
176 const long double v = negative ? -
_v :
_v;
179 long double flo = std::modf (v, &fhi);
188 const long double round = 0.5;
190 int64_t hi =
static_cast<int64_t
> (fhi);
191 uint64_t lo =
static_cast<uint64_t
> (flo);
206 return std::make_pair (hi, lo);
236 int64_t retval =
static_cast<int64_t
> (
_v);
248 int64_t retval = std::round (
_v);
330 return lhs._v == rhs._v;
339 inline bool operator < (
const int64x64_t & lhs,
const int64x64_t & rhs)
341 return lhs._v < rhs._v;
350 inline bool operator > (
const int64x64_t & lhs,
const int64x64_t & rhs)
352 return lhs._v > rhs._v;
362 inline int64x64_t &
operator += (int64x64_t & lhs,
const int64x64_t & rhs)
374 inline int64x64_t &
operator -= (int64x64_t & lhs,
const int64x64_t & rhs)
386 inline int64x64_t &
operator *= (int64x64_t & lhs,
const int64x64_t & rhs)
398 inline int64x64_t &
operator /= (int64x64_t & lhs,
const int64x64_t & rhs)
410 inline int64x64_t
operator + (
const int64x64_t & lhs)
420 inline int64x64_t
operator - (
const int64x64_t & lhs)
422 return int64x64_t (-lhs._v);
430 inline int64x64_t
operator ! (
const int64x64_t & lhs)
432 return int64x64_t (!lhs._v);
High precision numerical type, implementing Q64.64 fixed precision.
int64x64_t(unsigned long int v)
Construct from an integral type.
int64x64_t(int v)
Construct from an integral type.
friend bool operator==(const int64x64_t &lhs, const int64x64_t &rhs)
Arithmetic operator.
static const uint64_t HP_MASK_LO
Mask for fraction part.
friend int64x64_t & operator*=(int64x64_t &lhs, const int64x64_t &rhs)
Compound multiplication operator.
int64_t GetInt(void) const
Truncate to an integer.
int64x64_t & operator=(const int64x64_t &o)
Assignment.
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 int64x64_t Invert(uint64_t v)
Compute the inverse of an integer value.
int64x64_t(long double v)
Construct from a floating point value.
int64_t Round(void) const
Round to the nearest int.
int64x64_t(unsigned int v)
Construct from an integral type.
void MulByInvert(const int64x64_t &o)
Multiply this value by a Q0.128 value, presumably representing an inverse, completing a division oper...
friend bool operator<(const int64x64_t &lhs, const int64x64_t &rhs)
Less than operator.
friend int64x64_t & operator+=(int64x64_t &lhs, const int64x64_t &rhs)
Compound addition operator.
static enum impl_type implementation
Type tag for this implementation.
friend int64x64_t operator!(const int64x64_t &lhs)
Logical not operator.
int128_t _v
The Q64.64 value.
int64x64_t(unsigned long long int v)
Construct from an integral type.
int64_t GetHigh(void) const
Get the integer portion.
std::pair< int64_t, uint64_t > GetHighLow(void) const
Get the high and low portions of this value.
int64x64_t(long long int v)
Construct from an integral type.
uint64_t GetLow(void) const
Get the fractional portion of this value, unscaled.
friend int64x64_t & operator-=(int64x64_t &lhs, const int64x64_t &rhs)
Compound subtraction operator.
int64x64_t(int64_t hi, uint64_t lo)
Construct from explicit high and low values.
friend bool operator>(const int64x64_t &lhs, const int64x64_t &rhs)
Greater operator.
long double _v
The Q64.64 value.
double GetDouble(void) const
Get this value as a double.
friend int64x64_t operator-(const int64x64_t &lhs)
Unary operator.
int64x64_t(double v)
Construct from a floating point value.
friend int64x64_t & operator/=(int64x64_t &lhs, const int64x64_t &rhs)
Compound division operator.
int64x64_t(const int64x64_t &o)
Copy constructor.
int64x64_t()
Default constructor.
int64x64_t(long int v)
Construct from an integral type.
bool operator>(const int64x64_t &lhs, const int64x64_t &rhs)
Greater operator.
int64x64_t operator+(const int64x64_t &lhs)
Unary plus operator.
int64x64_t operator-(const int64x64_t &lhs)
Unary negation operator (change sign operator).
int64x64_t & operator/=(int64x64_t &lhs, const int64x64_t &rhs)
Compound division operator.
int64x64_t operator!(const int64x64_t &lhs)
Logical not operator.
int64x64_t & operator*=(int64x64_t &lhs, const int64x64_t &rhs)
Compound multiplication operator.
int64x64_t & operator+=(int64x64_t &lhs, const int64x64_t &rhs)
Compound addition operator.
int64x64_t & operator-=(int64x64_t &lhs, const int64x64_t &rhs)
Compound subtraction operator.
#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.
bool operator==(const EventId &a, const EventId &b)
bool operator<(const EventId &a, const EventId &b)