A Discrete-Event Network Simulator
API
ns3::int64x64_t Class Reference

High precision numerical type, implementing Q64.64 fixed precision. More...

#include "int64x64-128.h"

+ Collaboration diagram for ns3::int64x64_t:

Public Types

enum  impl_type {
  int128_impl, cairo_impl, ld_impl, int128_impl,
  cairo_impl, ld_impl, int128_impl, cairo_impl,
  ld_impl
}
 Type tag for the underlying implementation. More...
 
enum  impl_type {
  int128_impl, cairo_impl, ld_impl, int128_impl,
  cairo_impl, ld_impl, int128_impl, cairo_impl,
  ld_impl
}
 Type tag for the underlying implementation. More...
 
enum  impl_type {
  int128_impl, cairo_impl, ld_impl, int128_impl,
  cairo_impl, ld_impl, int128_impl, cairo_impl,
  ld_impl
}
 Type tag for the underlying implementation. More...
 

Public Member Functions

 int64x64_t ()
 Default constructor. More...
 
 int64x64_t ()
 Default constructor. More...
 
 int64x64_t ()
 Default constructor. More...
 
 int64x64_t (int64_t hi, uint64_t lo)
 Construct from explicit high and low values. More...
 
 int64x64_t (const int64x64_t &o)
 Copy constructor. More...
 
 int64x64_t (const int64_t hi, const uint64_t lo)
 Construct from explicit high and low values. More...
 
 int64x64_t (const int64_t hi, const uint64_t lo)
 Construct from explicit high and low values. More...
 
 int64x64_t (const int64x64_t &o)
 Copy constructor. More...
 
 int64x64_t (const int64x64_t &o)
 Copy constructor. More...
 
double GetDouble (void) const
 Get this value as a double. More...
 
double GetDouble (void) const
 Get this value as a double. More...
 
double GetDouble (void) const
 Get this value as a double. More...
 
int64_t GetHigh (void) const
 Get the integer portion. More...
 
int64_t GetHigh (void) const
 Get the integer portion. More...
 
int64_t GetHigh (void) const
 Get the integer portion. More...
 
uint64_t GetLow (void) const
 Get the fractional portion of this value, unscaled. More...
 
uint64_t GetLow (void) const
 Get the fractional portion of this value, unscaled. More...
 
uint64_t GetLow (void) const
 Get the fractional portion of this value, unscaled. More...
 
void MulByInvert (const int64x64_t &o)
 Multiply this value by a Q0.128 value, presumably representing an inverse, completing a division operation. More...
 
void MulByInvert (const int64x64_t &o)
 Multiply this value by a Q0.128 value, presumably representing an inverse, completing a division operation. More...
 
void MulByInvert (const int64x64_t &o)
 Multiply this value by a Q0.128 value, presumably representing an inverse, completing a division operation. More...
 
int64x64_toperator= (const int64x64_t &o)
 Assignment. More...
 
int64x64_toperator= (const int64x64_t &o)
 Assignment. More...
 
int64x64_toperator= (const int64x64_t &o)
 Assignment. More...
 
Construct from a floating point value.
Parameters
[in]valueFloating value to represent.
 int64x64_t (const double value)
 
 int64x64_t (const long double value)
 
Construct from an integral type.
Parameters
[in]vInteger value to represent.
 int64x64_t (const int v)
 
 int64x64_t (const long int v)
 
 int64x64_t (const long long int v)
 
 int64x64_t (const unsigned int v)
 
 int64x64_t (const unsigned long int v)
 
 int64x64_t (const unsigned long long int v)
 
 int64x64_t (const double value)
 Construct from a floating point value. More...
 
 int64x64_t (const long double value)
 Construct from a floating point value. More...
 
 int64x64_t (const int v)
 Construct from an integral type. More...
 
 int64x64_t (const long int v)
 Construct from an integral type. More...
 
 int64x64_t (const long long int v)
 Construct from an integral type. More...
 
 int64x64_t (const unsigned int v)
 Construct from an integral type. More...
 
 int64x64_t (const unsigned long int v)
 Construct from an integral type. More...
 
 int64x64_t (const unsigned long long int v)
 Construct from an integral type. More...
 
 int64x64_t (double v)
 Construct from a floating point value. More...
 
 int64x64_t (long double v)
 Construct from a floating point value. More...
 
 int64x64_t (int v)
 Construct from an integral type. More...
 
 int64x64_t (long int v)
 Construct from an integral type. More...
 
 int64x64_t (long long int v)
 Construct from an integral type. More...
 
 int64x64_t (unsigned int v)
 Construct from an integral type. More...
 
 int64x64_t (unsigned long int v)
 Construct from an integral type. More...
 
 int64x64_t (unsigned long long int v)
 Construct from an integral type. More...
 

Static Public Member Functions

static int64x64_t Invert (uint64_t v)
 Compute the inverse of an integer value. More...
 
static int64x64_t Invert (const uint64_t v)
 Compute the inverse of an integer value. More...
 
static int64x64_t Invert (const uint64_t v)
 Compute the inverse of an integer value. More...
 

Static Public Attributes

static enum impl_type implementation = int128_impl
 Type tag for this implementation. More...
 

Private Member Functions

 int64x64_t (const int128_t v)
 Construct from an integral type. More...
 
void Div (const int64x64_t &o)
 Implement /=. More...
 
void Div (const int64x64_t &o)
 Implement /=. More...
 
std::pair< int64_t, uint64_t > GetHighLow (void) const
 Get the high and low portions of this value. More...
 
void Mul (const int64x64_t &o)
 Implement *=. More...
 
void Mul (const int64x64_t &o)
 Implement *=. More...
 

Static Private Member Functions

static cairo_uint128_t Udiv (const cairo_uint128_t a, const cairo_uint128_t b)
 Unsigned division of Q64.64 values. More...
 
static uint128_t Udiv (const uint128_t a, const uint128_t b)
 Unsigned division of Q64.64 values. More...
 
static cairo_uint128_t Umul (const cairo_uint128_t a, const cairo_uint128_t b)
 Unsigned multiplication of Q64.64 values. More...
 
static uint128_t Umul (const uint128_t a, const uint128_t b)
 Unsigned multiplication of Q64.64 values. More...
 
static cairo_uint128_t UmulByInvert (const cairo_uint128_t a, const cairo_uint128_t b)
 Unsigned multiplication of Q64.64 and Q0.128 values. More...
 
static uint128_t UmulByInvert (const uint128_t a, const uint128_t b)
 Unsigned multiplication of Q64.64 and Q0.128 values. More...
 

Private Attributes

long double _v
 The Q64.64 value. More...
 
cairo_int128_t _v
 The Q64.64 value. More...
 
int128_t _v
 The Q64.64 value. More...
 

Static Private Attributes

static const uint128_t HP128_MASK_HI_BIT = (((int128_t)1)<<127)
 uint128_t high bit (sign bit). More...
 
static const uint64_t HP_MASK_HI = ~HP_MASK_LO
 Mask for sign + integer part. More...
 
static const uint64_t HP_MASK_LO = 0xffffffffffffffffULL
 Mask for fraction part. More...
 
static const uint64_t HPCAIRO_MASK_HI_BIT = (((uint64_t)1)<<63)
 High bit of fractional part. More...
 

Friends

int64x64_t operator! (const int64x64_t &lhs)
 Logical not operator. More...
 
int64x64_t operator! (const int64x64_t &lhs)
 Logical not operator. More...
 
int64x64_t operator! (const int64x64_t &lhs)
 Logical not operator. More...
 
int64x64_toperator*= (int64x64_t &lhs, const int64x64_t &rhs)
 Compound multiplication operator. More...
 
int64x64_toperator*= (int64x64_t &lhs, const int64x64_t &rhs)
 Compound multiplication operator. More...
 
int64x64_toperator*= (int64x64_t &lhs, const int64x64_t &rhs)
 Compound multiplication operator. More...
 
int64x64_toperator+= (int64x64_t &lhs, const int64x64_t &rhs)
 Compound addition operator. More...
 
int64x64_toperator+= (int64x64_t &lhs, const int64x64_t &rhs)
 Compound addition operator. More...
 
int64x64_toperator+= (int64x64_t &lhs, const int64x64_t &rhs)
 Compound addition operator. More...
 
int64x64_t operator- (const int64x64_t &lhs)
 Unary negation operator (change sign operator). More...
 
int64x64_t operator- (const int64x64_t &lhs)
 Unary negation operator (change sign operator). More...
 
int64x64_t operator- (const int64x64_t &lhs)
 Unary negation operator (change sign operator). More...
 
int64x64_toperator-= (int64x64_t &lhs, const int64x64_t &rhs)
 Compound subtraction operator. More...
 
int64x64_toperator-= (int64x64_t &lhs, const int64x64_t &rhs)
 Compound subtraction operator. More...
 
int64x64_toperator-= (int64x64_t &lhs, const int64x64_t &rhs)
 Compound subtraction operator. More...
 
int64x64_toperator/= (int64x64_t &lhs, const int64x64_t &rhs)
 Compound division operator. More...
 
int64x64_toperator/= (int64x64_t &lhs, const int64x64_t &rhs)
 Compound division operator. More...
 
int64x64_toperator/= (int64x64_t &lhs, const int64x64_t &rhs)
 Compound division operator. More...
 
bool operator< (const int64x64_t &lhs, const int64x64_t &rhs)
 Less than operator. More...
 
bool operator< (const int64x64_t &lhs, const int64x64_t &rhs)
 Less than operator. More...
 
bool operator< (const int64x64_t &lhs, const int64x64_t &rhs)
 Less than operator. More...
 
bool operator== (const int64x64_t &lhs, const int64x64_t &rhs)
 Equality operator. More...
 
bool operator== (const int64x64_t &lhs, const int64x64_t &rhs)
 Equality operator. More...
 
bool operator== (const int64x64_t &lhs, const int64x64_t &rhs)
 Equality operator. More...
 
bool operator> (const int64x64_t &lhs, const int64x64_t &rhs)
 Greater operator. More...
 
bool operator> (const int64x64_t &lhs, const int64x64_t &rhs)
 Greater operator. More...
 
bool operator> (const int64x64_t &lhs, const int64x64_t &rhs)
 Greater operator. More...
 

Detailed Description

High precision numerical type, implementing Q64.64 fixed precision.

Internal:
The implementation documented here is based on native 128-bit integers.
Internal:
The implementation documented here uses cairo 128-bit integers.
Internal:
The implementation documented here uses native long double.

Definition at line 45 of file int64x64-128.h.

Member Enumeration Documentation

Type tag for the underlying implementation.

A few testcases are are sensitive to implementation, specifically the double implementation. To handle this, we expose the underlying implementation type here.

Enumerator
int128_impl 

Native int128_t implementation.

Native int128_t implementation.

cairo_impl 

Cairo wideint implementation.

cairo wideint implementation

ld_impl 

long double implementation.

long double implementation

int128_impl 

Native int128_t implementation.

Native int128_t implementation.

cairo_impl 

Cairo wideint implementation.

cairo wideint implementation

ld_impl 

long double implementation.

long double implementation

int128_impl 

Native int128_t implementation.

Native int128_t implementation.

cairo_impl 

Cairo wideint implementation.

cairo wideint implementation

ld_impl 

long double implementation.

long double implementation

Definition at line 67 of file int64x64-double.h.

Type tag for the underlying implementation.

A few testcases are sensitive to implementation, specifically the double implementation. To handle this, we expose the underlying implementation type here.

Enumerator
int128_impl 

Native int128_t implementation.

Native int128_t implementation.

cairo_impl 

Cairo wideint implementation.

cairo wideint implementation

ld_impl 

long double implementation.

long double implementation

int128_impl 

Native int128_t implementation.

Native int128_t implementation.

cairo_impl 

Cairo wideint implementation.

cairo wideint implementation

ld_impl 

long double implementation.

long double implementation

int128_impl 

Native int128_t implementation.

Native int128_t implementation.

cairo_impl 

Cairo wideint implementation.

cairo wideint implementation

ld_impl 

long double implementation.

long double implementation

Definition at line 68 of file int64x64-cairo.h.

Type tag for the underlying implementation.

A few testcases are are sensitive to implementation, specifically the double implementation. To handle this, we expose the underlying implementation type here.

Enumerator
int128_impl 

Native int128_t implementation.

Native int128_t implementation.

cairo_impl 

Cairo wideint implementation.

cairo wideint implementation

ld_impl 

long double implementation.

long double implementation

int128_impl 

Native int128_t implementation.

Native int128_t implementation.

cairo_impl 

Cairo wideint implementation.

cairo wideint implementation

ld_impl 

long double implementation.

long double implementation

int128_impl 

Native int128_t implementation.

Native int128_t implementation.

cairo_impl 

Cairo wideint implementation.

cairo wideint implementation

ld_impl 

long double implementation.

long double implementation

Definition at line 76 of file int64x64-128.h.

Constructor & Destructor Documentation

ns3::int64x64_t::int64x64_t ( )
inline

Default constructor.

Definition at line 86 of file int64x64-128.h.

Referenced by Invert(), ns3::operator!(), ns3::operator-(), and UmulByInvert().

+ Here is the caller graph for this function:

ns3::int64x64_t::int64x64_t ( const double  value)
inline

Definition at line 94 of file int64x64-128.h.

References _v.

ns3::int64x64_t::int64x64_t ( const long double  value)
inline

Definition at line 99 of file int64x64-128.h.

References _v, and HP_MAX_64.

ns3::int64x64_t::int64x64_t ( const int  v)
inline

Definition at line 135 of file int64x64-128.h.

References _v.

ns3::int64x64_t::int64x64_t ( const long int  v)
inline

Definition at line 140 of file int64x64-128.h.

References _v.

ns3::int64x64_t::int64x64_t ( const long long int  v)
inline

Definition at line 145 of file int64x64-128.h.

References _v.

ns3::int64x64_t::int64x64_t ( const unsigned int  v)
inline

Definition at line 150 of file int64x64-128.h.

References _v.

ns3::int64x64_t::int64x64_t ( const unsigned long int  v)
inline

Definition at line 155 of file int64x64-128.h.

References _v.

ns3::int64x64_t::int64x64_t ( const unsigned long long int  v)
inline

Definition at line 160 of file int64x64-128.h.

References _v.

ns3::int64x64_t::int64x64_t ( const int64_t  hi,
const uint64_t  lo 
)
inlineexplicit

Construct from explicit high and low values.

Parameters
[in]hiInteger portion.
[in]loFractional portion, already scaled to HP_MAX_64.

Definition at line 173 of file int64x64-128.h.

References _v.

ns3::int64x64_t::int64x64_t ( const int64x64_t o)
inline

Copy constructor.

Parameters
[in]oValue to copy.

Definition at line 184 of file int64x64-128.h.

ns3::int64x64_t::int64x64_t ( const int128_t  v)
inlineprivate

Construct from an integral type.

Parameters
[in]vInteger value to represent.

Definition at line 336 of file int64x64-128.h.

ns3::int64x64_t::int64x64_t ( )
inline

Default constructor.

Definition at line 78 of file int64x64-cairo.h.

References _v.

ns3::int64x64_t::int64x64_t ( const double  value)
inline

Construct from a floating point value.

Parameters
[in]valuefloating value to represent

Definition at line 89 of file int64x64-cairo.h.

References _v.

ns3::int64x64_t::int64x64_t ( const long double  value)
inline

Construct from a floating point value.

Parameters
[in]valuefloating value to represent

Definition at line 94 of file int64x64-cairo.h.

References _cairo_int128_negate, _v, and HP_MAX_64.

ns3::int64x64_t::int64x64_t ( const int  v)
inline

Construct from an integral type.

Parameters
[in]vInteger value to represent

Definition at line 130 of file int64x64-cairo.h.

References _v.

ns3::int64x64_t::int64x64_t ( const long int  v)
inline

Construct from an integral type.

Parameters
[in]vInteger value to represent

Definition at line 135 of file int64x64-cairo.h.

References _v.

ns3::int64x64_t::int64x64_t ( const long long int  v)
inline

Construct from an integral type.

Parameters
[in]vInteger value to represent

Definition at line 140 of file int64x64-cairo.h.

References _v.

ns3::int64x64_t::int64x64_t ( const unsigned int  v)
inline

Construct from an integral type.

Parameters
[in]vInteger value to represent

Definition at line 145 of file int64x64-cairo.h.

References _v.

ns3::int64x64_t::int64x64_t ( const unsigned long int  v)
inline

Construct from an integral type.

Parameters
[in]vInteger value to represent

Definition at line 150 of file int64x64-cairo.h.

References _v.

ns3::int64x64_t::int64x64_t ( const unsigned long long int  v)
inline

Construct from an integral type.

Parameters
[in]vInteger value to represent

Definition at line 155 of file int64x64-cairo.h.

References _v.

ns3::int64x64_t::int64x64_t ( const int64_t  hi,
const uint64_t  lo 
)
inlineexplicit

Construct from explicit high and low values.

Parameters
[in]hiInteger portion.
[in]loFractional portion, already scaled to HP_MAX_64.

Definition at line 167 of file int64x64-cairo.h.

References _v.

ns3::int64x64_t::int64x64_t ( const int64x64_t o)
inline

Copy constructor.

Parameters
[in]oValue to copy.

Definition at line 178 of file int64x64-cairo.h.

ns3::int64x64_t::int64x64_t ( )
inline

Default constructor.

Definition at line 77 of file int64x64-double.h.

ns3::int64x64_t::int64x64_t ( double  v)
inline

Construct from a floating point value.

Parameters
[in]vFloating value to represent

Definition at line 85 of file int64x64-double.h.

ns3::int64x64_t::int64x64_t ( long double  v)
inline

Construct from a floating point value.

Parameters
[in]vFloating value to represent

Definition at line 87 of file int64x64-double.h.

ns3::int64x64_t::int64x64_t ( int  v)
inline

Construct from an integral type.

Parameters
[in]vInteger value to represent

Definition at line 97 of file int64x64-double.h.

ns3::int64x64_t::int64x64_t ( long int  v)
inline

Construct from an integral type.

Parameters
[in]vInteger value to represent

Definition at line 99 of file int64x64-double.h.

ns3::int64x64_t::int64x64_t ( long long int  v)
inline

Construct from an integral type.

Parameters
[in]vInteger value to represent

Definition at line 101 of file int64x64-double.h.

ns3::int64x64_t::int64x64_t ( unsigned int  v)
inline

Construct from an integral type.

Parameters
[in]vInteger value to represent

Definition at line 103 of file int64x64-double.h.

ns3::int64x64_t::int64x64_t ( unsigned long int  v)
inline

Construct from an integral type.

Parameters
[in]vInteger value to represent

Definition at line 105 of file int64x64-double.h.

ns3::int64x64_t::int64x64_t ( unsigned long long int  v)
inline

Construct from an integral type.

Parameters
[in]vInteger value to represent

Definition at line 107 of file int64x64-double.h.

ns3::int64x64_t::int64x64_t ( int64_t  hi,
uint64_t  lo 
)
inlineexplicit

Construct from explicit high and low values.

Parameters
[in]hiInteger portion.
[in]loFractional portion, already scaled to HP_MAX_64.

Definition at line 116 of file int64x64-double.h.

References _v, and HP_MAX_64.

ns3::int64x64_t::int64x64_t ( const int64x64_t o)
inline

Copy constructor.

Parameters
[in]oValue to copy.

Definition at line 132 of file int64x64-double.h.

Member Function Documentation

void ns3::int64x64_t::Div ( const int64x64_t o)
private

Implement /=.

Parameters
[in]oThe divisor.
void ns3::int64x64_t::Div ( const int64x64_t o)
private

Implement /=.

Parameters
[in]oThe divisor.

Definition at line 113 of file int64x64-128.cc.

References _v, ns3::output_sign(), and Udiv().

Referenced by GetLow(), ns3::operator/=(), and Umul().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double ns3::int64x64_t::GetDouble ( void  ) const
inline

Get this value as a double.

Returns
This value in floating form.

Definition at line 150 of file int64x64-double.h.

References _v.

double ns3::int64x64_t::GetDouble ( void  ) const
inline

Get this value as a double.

Returns
This value in floating form.

Definition at line 196 of file int64x64-cairo.h.

References _cairo_int128_negate, _cairo_int128_negative, _v, cairo_int128_t::hi, HP_MAX_64, and cairo_int128_t::lo.

double ns3::int64x64_t::GetDouble ( void  ) const
inline

Get this value as a double.

Returns
This value in floating form.

Definition at line 203 of file int64x64-128.h.

References _v, HP_MASK_LO, and HP_MAX_64.

Referenced by ns3::int64x64::test::Int64x64Bug455TestCase::DoRun(), ns3::int64x64::test::Int64x64Bug863TestCase::DoRun(), and ns3::Time::ToDouble().

+ Here is the caller graph for this function:

int64_t ns3::int64x64_t::GetHigh ( void  ) const
inline

Get the integer portion.

Returns
The integer portion of this value.

Definition at line 201 of file int64x64-double.h.

References GetHighLow().

+ Here is the call graph for this function:

int64_t ns3::int64x64_t::GetHigh ( void  ) const
inline

Get the integer portion.

Returns
The integer portion of this value.

Definition at line 212 of file int64x64-cairo.h.

References _v.

int64_t ns3::int64x64_t::GetHigh ( void  ) const
inline

Get the integer portion.

Returns
The integer portion of this value.

Definition at line 219 of file int64x64-128.h.

References _v.

Referenced by ns3::OnOffApplication::CancelEvents(), ns3::int64x64::test::Int64x64HiLoTestCase::Check(), ns3::DelayJitterEstimation::GetLastJitter(), Invert(), ns3::operator<<(), and UmulByInvert().

+ Here is the caller graph for this function:

std::pair<int64_t, uint64_t> ns3::int64x64_t::GetHighLow ( void  ) const
inlineprivate

Get the high and low portions of this value.

Returns
A pair of the high and low words

Definition at line 160 of file int64x64-double.h.

References _v, and HP_MAX_64.

Referenced by GetHigh(), and GetLow().

+ Here is the caller graph for this function:

uint64_t ns3::int64x64_t::GetLow ( void  ) const
inline

Get the fractional portion of this value, unscaled.

Returns
The fractional portion, unscaled, as an integer.

Definition at line 210 of file int64x64-double.h.

References GetHighLow().

+ Here is the call graph for this function:

uint64_t ns3::int64x64_t::GetLow ( void  ) const
inline

Get the fractional portion of this value, unscaled.

Returns
The fractional portion, unscaled, as an integer.

Definition at line 221 of file int64x64-cairo.h.

References _v, Div(), Invert(), Mul(), MulByInvert(), operator!, operator*=, operator+=, operator-, operator-=, operator/=, operator<, operator==, operator>, Udiv(), Umul(), and UmulByInvert().

+ Here is the call graph for this function:

uint64_t ns3::int64x64_t::GetLow ( void  ) const
inline

Get the fractional portion of this value, unscaled.

Returns
The fractional portion, unscaled, as an integer.

Definition at line 229 of file int64x64-128.h.

References _v, Div(), HP_MASK_LO, Invert(), Mul(), MulByInvert(), operator!, operator*=, operator+=, operator-, operator-=, operator/=, operator<, operator==, operator>, Udiv(), Umul(), and UmulByInvert().

Referenced by ns3::int64x64::test::Int64x64HiLoTestCase::Check(), ns3::int64x64::test::Int64x64InputTestCase::Check(), ns3::operator<<(), and ns3::ReadLoDigits().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int64x64_t ns3::int64x64_t::Invert ( uint64_t  v)
inlinestatic

Compute the inverse of an integer value.

Parameters
[in]vThe value to compute the inverse of.
Returns
The inverse.

Definition at line 235 of file int64x64-double.h.

References operator!, operator*=, operator+=, operator-, operator-=, operator/=, operator<, operator==, and operator>.

static int64x64_t ns3::int64x64_t::Invert ( const uint64_t  v)
static

Compute the inverse of an integer value.

Ordinary division by an integer would be limited to 64 bits of precsion. Instead, we multiply by the 128-bit inverse of the divisor. This function computes the inverse to 128-bit precision. MulByInvert() then completes the division.

(Really this should be a separate type representing Q0.128.)

Parameters
[in]vThe value to compute the inverse of.
Returns
A Q0.128 representation of the inverse.
int64x64_t ns3::int64x64_t::Invert ( const uint64_t  v)
static

Compute the inverse of an integer value.

Ordinary division by an integer would be limited to 64 bits of precision. Instead, we multiply by the 128-bit inverse of the divisor. This function computes the inverse to 128-bit precision. MulByInvert() then completes the division.

(Really this should be a separate type representing Q0.128.)

Parameters
[in]vThe value to compute the inverse of.
Returns
A Q0.128 representation of the inverse.

Definition at line 217 of file int64x64-128.cc.

References _v, GetHigh(), int64x64_t(), MulByInvert(), NS_ASSERT, and Udiv().

Referenced by ns3::int64x64::test::Int64x64InvertTestCase::Check(), GetLow(), ns3::Time::SetResolution(), and UmulByInvert().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::int64x64_t::Mul ( const int64x64_t o)
private

Implement *=.

Parameters
[in]oThe other factor.
void ns3::int64x64_t::Mul ( const int64x64_t o)
private

Implement *=.

Parameters
[in]oThe other factor.

Definition at line 64 of file int64x64-128.cc.

References _v, ns3::output_sign(), and Umul().

Referenced by GetLow(), ns3::operator*=(), and ns3::output_sign().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::int64x64_t::MulByInvert ( const int64x64_t o)
inline

Multiply this value by a Q0.128 value, presumably representing an inverse, completing a division operation.

Parameters
[in]oThe inverse operand.
Note
There is no difference between Q64.64 and Q0.128 in this implementation, so this function is a simple multiply.

Definition at line 224 of file int64x64-double.h.

References _v.

void ns3::int64x64_t::MulByInvert ( const int64x64_t o)

Multiply this value by a Q0.128 value, presumably representing an inverse, completing a division operation.

Parameters
[in]oThe inverse operand.
See also
Invert
void ns3::int64x64_t::MulByInvert ( const int64x64_t o)

Multiply this value by a Q0.128 value, presumably representing an inverse, completing a division operation.

Parameters
[in]oThe inverse operand.
See also
Invert()

Definition at line 191 of file int64x64-128.cc.

References _v, and UmulByInvert().

Referenced by ns3::int64x64::test::Int64x64InvertTestCase::Check(), ns3::Time::From(), GetLow(), Invert(), ns3::Time::To(), Udiv(), and UmulByInvert().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64x64_t& ns3::int64x64_t::operator= ( const int64x64_t o)
inline

Assignment.

Parameters
[in]oValue to assign to this int64x64_t.

Definition at line 139 of file int64x64-double.h.

References _v.

int64x64_t& ns3::int64x64_t::operator= ( const int64x64_t o)
inline

Assignment.

Parameters
[in]oValue to assign to this int64x64_t.

Definition at line 185 of file int64x64-cairo.h.

References _v.

int64x64_t& ns3::int64x64_t::operator= ( const int64x64_t o)
inline

Assignment.

Parameters
[in]oValue to assign to this int64x64_t.
Returns
This int64x64_t.

Definition at line 192 of file int64x64-128.h.

References _v.

cairo_uint128_t ns3::int64x64_t::Udiv ( const cairo_uint128_t  a,
const cairo_uint128_t  b 
)
staticprivate

Unsigned division of Q64.64 values.

Parameters
[in]aNumerator.
[in]bDenominator.
Returns
The Q64.64 representation of a / b

Definition at line 128 of file int64x64-cairo.cc.

References _cairo_int128_lsl, _cairo_int128_negate, _cairo_int128_negative, _cairo_uint128_add(), _cairo_uint128_divrem(), _cairo_uint128_eq(), _cairo_uint128_lsl(), _cairo_uint128_lt(), _cairo_uint128_rsl(), _cairo_uint32_to_uint128(), _v, HPCAIRO_MASK_HI_BIT, MulByInvert(), NS_ASSERT_MSG(), cairo_uquorem128_t::quo, cairo_uquorem128_t::rem, and UmulByInvert().

+ Here is the call graph for this function:

uint128_t ns3::int64x64_t::Udiv ( const uint128_t  a,
const uint128_t  b 
)
staticprivate

Unsigned division of Q64.64 values.

Parameters
[in]aNumerator.
[in]bDenominator.
Returns
The Q64.64 representation of a / b.

Definition at line 122 of file int64x64-128.cc.

References HP128_MASK_HI_BIT, and NS_ASSERT_MSG().

Referenced by Div(), GetLow(), Invert(), Umul(), and UmulByInvert().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

cairo_uint128_t ns3::int64x64_t::Umul ( const cairo_uint128_t  a,
const cairo_uint128_t  b 
)
staticprivate

Unsigned multiplication of Q64.64 values.

Mathematically this should produce a Q128.128 value; we keep the central 128 bits, representing the Q64.64 result. We assert on integer overflow beyond the 64-bit integer portion.

Parameters
[in]aFirst factor.
[in]bSecond factor.
Returns
The Q64.64 product.
Internal:

It might be tempting to just use a * b and be done with it, but it's not that simple. With a and b as 128-bit integers, a * b mathematically produces a 256-bit result, which the computer truncates to the lowest 128 bits. In our case, where a and b are interpreted as Q64.64 fixed point numbers, the multiplication mathematically produces a Q128.128 fixed point number. We want the middle 128 bits from the result, truncating both the high and low 64 bits. To achieve this, we carry out the multiplication explicitly with 64-bit operands and 128-bit intermediate results.

Definition at line 83 of file int64x64-cairo.cc.

References _cairo_uint128_add(), _cairo_uint128_lsl(), _cairo_uint128_negate(), _cairo_uint64_to_uint128(), _cairo_uint64x64_128_mul(), _v, Div(), NS_ABORT_MSG_IF, ns3::output_sign(), and Udiv().

+ Here is the call graph for this function:

uint128_t ns3::int64x64_t::Umul ( const uint128_t  a,
const uint128_t  b 
)
staticprivate

Unsigned multiplication of Q64.64 values.

Mathematically this should produce a Q128.128 value; we keep the central 128 bits, representing the Q64.64 result. We assert on integer overflow beyond the 64-bit integer portion.

Parameters
[in]aFirst factor.
[in]bSecond factor.
Returns
The Q64.64 product.
Internal:

It might be tempting to just use a * b and be done with it, but it's not that simple. With a and b as 128-bit integers, a * b mathematically produces a 256-bit result, which the computer truncates to the lowest 128 bits. In our case, where a and b are interpreted as Q64.64 fixed point numbers, the multiplication mathematically produces a Q128.128 fixed point number. We want the middle 128 bits from the result, truncating both the high and low 64 bits. To achieve this, we carry out the multiplication explicitly with 64-bit operands and 128-bit intermediate results.

Definition at line 73 of file int64x64-128.cc.

References HP_MASK_HI, HP_MASK_LO, and NS_ABORT_MSG_IF.

Referenced by GetLow(), Mul(), and ns3::output_sign().

+ Here is the caller graph for this function:

cairo_uint128_t ns3::int64x64_t::UmulByInvert ( const cairo_uint128_t  a,
const cairo_uint128_t  b 
)
staticprivate

Unsigned multiplication of Q64.64 and Q0.128 values.

Parameters
[in]aThe numerator, a Q64.64 value.
[in]bThe inverse of the denominator, a Q0.128 value
Returns
The product a * b, representing the ration a / b^-1
See also
Invert

Definition at line 204 of file int64x64-cairo.cc.

References _cairo_uint128_add(), _cairo_uint64x64_128_mul(), _v, GetHigh(), int64x64_t(), Invert(), MulByInvert(), NS_ASSERT, and Udiv().

+ Here is the call graph for this function:

uint128_t ns3::int64x64_t::UmulByInvert ( const uint128_t  a,
const uint128_t  b 
)
staticprivate

Unsigned multiplication of Q64.64 and Q0.128 values.

Parameters
[in]aThe numerator, a Q64.64 value.
[in]bThe inverse of the denominator, a Q0.128 value
Returns
The product a * b, representing the ration a / b^-1.
See also
Invert()

Definition at line 201 of file int64x64-128.cc.

References HP_MASK_LO.

Referenced by GetLow(), MulByInvert(), and Udiv().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

int64x64_t operator! ( const int64x64_t lhs)
friend

Logical not operator.

Definition at line 426 of file int64x64-128.h.

int64x64_t operator! ( const int64x64_t lhs)
friend

Logical not operator.

Definition at line 426 of file int64x64-128.h.

int64x64_t operator! ( const int64x64_t lhs)
friend

Logical not operator.

Definition at line 426 of file int64x64-128.h.

Referenced by GetLow(), and Invert().

int64x64_t& operator*= ( int64x64_t lhs,
const int64x64_t rhs 
)
friend

Compound multiplication operator.

Definition at line 391 of file int64x64-128.h.

int64x64_t& operator*= ( int64x64_t lhs,
const int64x64_t rhs 
)
friend

Compound multiplication operator.

Definition at line 391 of file int64x64-128.h.

int64x64_t& operator*= ( int64x64_t lhs,
const int64x64_t rhs 
)
friend

Compound multiplication operator.

Definition at line 391 of file int64x64-128.h.

Referenced by GetLow(), and Invert().

int64x64_t& operator+= ( int64x64_t lhs,
const int64x64_t rhs 
)
friend

Compound addition operator.

Definition at line 373 of file int64x64-128.h.

int64x64_t& operator+= ( int64x64_t lhs,
const int64x64_t rhs 
)
friend

Compound addition operator.

Definition at line 373 of file int64x64-128.h.

int64x64_t& operator+= ( int64x64_t lhs,
const int64x64_t rhs 
)
friend

Compound addition operator.

Definition at line 373 of file int64x64-128.h.

Referenced by GetLow(), and Invert().

int64x64_t operator- ( const int64x64_t lhs)
friend

Unary negation operator (change sign operator).

Unary negation operator (change sign operator)

Definition at line 418 of file int64x64-128.h.

int64x64_t operator- ( const int64x64_t lhs)
friend

Unary negation operator (change sign operator).

Unary negation operator (change sign operator)

Definition at line 418 of file int64x64-128.h.

int64x64_t operator- ( const int64x64_t lhs)
friend

Unary negation operator (change sign operator).

Unary negation operator (change sign operator)

Definition at line 418 of file int64x64-128.h.

Referenced by GetLow(), and Invert().

int64x64_t& operator-= ( int64x64_t lhs,
const int64x64_t rhs 
)
friend

Compound subtraction operator.

Definition at line 382 of file int64x64-128.h.

int64x64_t& operator-= ( int64x64_t lhs,
const int64x64_t rhs 
)
friend

Compound subtraction operator.

Definition at line 382 of file int64x64-128.h.

int64x64_t& operator-= ( int64x64_t lhs,
const int64x64_t rhs 
)
friend

Compound subtraction operator.

Definition at line 382 of file int64x64-128.h.

Referenced by GetLow(), and Invert().

int64x64_t& operator/= ( int64x64_t lhs,
const int64x64_t rhs 
)
friend

Compound division operator.

Definition at line 400 of file int64x64-128.h.

int64x64_t& operator/= ( int64x64_t lhs,
const int64x64_t rhs 
)
friend

Compound division operator.

Definition at line 400 of file int64x64-128.h.

int64x64_t& operator/= ( int64x64_t lhs,
const int64x64_t rhs 
)
friend

Compound division operator.

Definition at line 400 of file int64x64-128.h.

Referenced by GetLow(), and Invert().

bool operator< ( const int64x64_t lhs,
const int64x64_t rhs 
)
friend

Less than operator.

Definition at line 356 of file int64x64-128.h.

bool operator< ( const int64x64_t lhs,
const int64x64_t rhs 
)
friend

Less than operator.

Definition at line 356 of file int64x64-128.h.

bool operator< ( const int64x64_t lhs,
const int64x64_t rhs 
)
friend

Less than operator.

Definition at line 356 of file int64x64-128.h.

Referenced by GetLow(), and Invert().

bool operator== ( const int64x64_t lhs,
const int64x64_t rhs 
)
friend

Equality operator.

Definition at line 348 of file int64x64-128.h.

bool operator== ( const int64x64_t lhs,
const int64x64_t rhs 
)
friend

Equality operator.

Definition at line 348 of file int64x64-128.h.

bool operator== ( const int64x64_t lhs,
const int64x64_t rhs 
)
friend

Equality operator.

Definition at line 348 of file int64x64-128.h.

Referenced by GetLow(), and Invert().

bool operator> ( const int64x64_t lhs,
const int64x64_t rhs 
)
friend

Greater operator.

Definition at line 364 of file int64x64-128.h.

bool operator> ( const int64x64_t lhs,
const int64x64_t rhs 
)
friend

Greater operator.

Definition at line 364 of file int64x64-128.h.

bool operator> ( const int64x64_t lhs,
const int64x64_t rhs 
)
friend

Greater operator.

Definition at line 364 of file int64x64-128.h.

Referenced by GetLow(), and Invert().

Member Data Documentation

long double ns3::int64x64_t::_v
private

The Q64.64 value.

Definition at line 255 of file int64x64-double.h.

cairo_int128_t ns3::int64x64_t::_v
private

The Q64.64 value.

Definition at line 321 of file int64x64-cairo.h.

const uint128_t ns3::int64x64_t::HP128_MASK_HI_BIT = (((int128_t)1)<<127)
staticprivate

uint128_t high bit (sign bit).

Definition at line 48 of file int64x64-128.h.

Referenced by Udiv().

const uint64_t ns3::int64x64_t::HP_MASK_HI = ~HP_MASK_LO
staticprivate

Mask for sign + integer part.

Definition at line 52 of file int64x64-128.h.

Referenced by Umul().

static const uint64_t ns3::int64x64_t::HP_MASK_LO = 0xffffffffffffffffULL
staticprivate

Mask for fraction part.

Definition at line 50 of file int64x64-128.h.

Referenced by GetDouble(), GetLow(), Umul(), and UmulByInvert().

const uint64_t ns3::int64x64_t::HPCAIRO_MASK_HI_BIT = (((uint64_t)1)<<63)
staticprivate

High bit of fractional part.

Definition at line 43 of file int64x64-cairo.h.

Referenced by Udiv().


The documentation for this class was generated from the following files: