81 uint128_t hiPart, loPart, midPart;
90 midPart = aL * bH + aH * bL;
95 "High precision 128 bits multiplication error: multiplication overflow.");
102 res1 = midPart >> 64;
127 uint128_t quo = rem / den;
132 const uint64_t DIGITS = 64;
133 const uint128_t ZERO = 0;
136 "Remainder not less than divisor");
142 while ( (shift < DIGITS) && !(den & 0x1))
148 while ( (digis < DIGITS) && (rem != ZERO) )
151 while ( (digis + shift < DIGITS)
152 && !(rem & HP128_MASK_HI_BIT))
162 while ( (digis + shift < DIGITS)
163 && ( !(den & 0x1) || (rem < den) ) )
183 shift = DIGITS - digis;
193 bool negResult =
_v < 0;
194 uint128_t a = negResult ? -
_v :
_v;
203 uint128_t
result, ah, bh, al, bl;
210 mid = ah * bl + al * bh;
NS_ABORT_x macro definitions.
NS_ASSERT() and NS_ASSERT_MSG() macro definitions.
High precision numerical type, implementing Q64.64 fixed precision.
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.
static cairo_uint128_t UmulByInvert(const cairo_uint128_t a, const cairo_uint128_t b)
Unsigned multiplication of Q64.64 and Q0.128 values.
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.
cairo_int128_t _v
The Q64.64 value.
int64_t GetHigh(void) const
Get the integer portion.
void Div(const int64x64_t &o)
Implement /=.
static int64x64_t Invert(const uint64_t v)
Compute the inverse of an integer value.
int64x64_t()
Default constructor.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
static bool output_sign(const int128_t sa, const int128_t sb, uint128_t &ua, uint128_t &ub)
Compute the sign of the result of multiplying or dividing Q64.64 fixed precision operands.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Every class exported by the ns3 library is enclosed in the ns3 namespace.