20 #include "ns3/core-config.h"
21 #if !defined(INT64X64_DOUBLE_H) && (defined (INT64X64_USE_DOUBLE) || defined(PYTHON_SCAN))
23 #define INT64X64_DOUBLE_H
45 static const uint64_t
HP_MASK_LO = 0xffffffffffffffffULL;
58 #define HP_MAX_64 (std::pow (2.0L, 64))
115 :
_v (static_cast<
long double> (v))
124 :
_v (static_cast<
long double> (v))
135 const bool negative = hi < 0;
136 const long double hild =
static_cast<long double> (hi);
137 const long double fhi = negative ? -hild : hild;
139 _v = negative ? -fhi : fhi;
165 inline explicit operator bool ()
const
188 const bool negative =
_v < 0;
189 const long double v = negative ? -
_v :
_v;
192 long double flo = std::modf (v, &fhi);
201 const long double round = 0.5;
203 int64_t hi =
static_cast<int64_t
> (fhi);
204 uint64_t lo =
static_cast<uint64_t
> (flo);
219 return std::make_pair (hi, lo);
249 int64_t retval =
static_cast<int64_t
> (
_v);
261 int64_t retval = std::round (
_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)
Arithmetic 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.
friend int64x64_t operator+(const int64x64_t &lhs)
Unary operator.
int64_t Round(void) const
Round to the nearest int.
int64x64_t(long double value)
Constructor from a floating point.
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)
Arithmetic operator.
friend int64x64_t & operator+=(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.
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)
Arithmetic 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)
Arithmetic operator.
long double _v
The Q64.64 value.
double GetDouble(void) const
Get this value as a double.
int64x64_t(double value)
Constructor from a floating point.
friend int64x64_t operator-(const int64x64_t &lhs)
Unary operator.
friend int64x64_t & operator/=(int64x64_t &lhs, const int64x64_t &rhs)
Arithmetic operator.
int64x64_t(const int64x64_t &o)
Copy constructor.
int64x64_t()
Default constructor.
int64x64_t(long int v)
Construct from an integral type.
#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.