A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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.
 
 int64x64_t ()
 Default constructor.
 
 int64x64_t ()
 Default constructor.
 
 int64x64_t (const int64_t hi, const uint64_t lo)
 Construct from explicit high and low values.
 
 int64x64_t (const int64_t hi, const uint64_t lo)
 Construct from explicit high and low values.
 
 int64x64_t (const int64x64_t &o)
 Copy constructor.
 
 int64x64_t (const int64x64_t &o)
 Copy constructor.
 
 int64x64_t (const int64x64_t &o)
 Copy constructor.
 
 int64x64_t (int64_t hi, uint64_t lo)
 Construct from explicit high and low values.
 
double GetDouble () const
 Get this value as a double.
 
double GetDouble () const
 Get this value as a double.
 
double GetDouble () const
 Get this value as a double.
 
int64_t GetHigh () const
 Get the integer portion.
 
int64_t GetHigh () const
 Get the integer portion.
 
int64_t GetHigh () const
 Get the integer portion.
 
int64_t GetInt () const
 Truncate to an integer.
 
int64_t GetInt () const
 Truncate to an integer.
 
int64_t GetInt () const
 Truncate to an integer.
 
uint64_t GetLow () const
 Get the fractional portion of this value, unscaled.
 
uint64_t GetLow () const
 Get the fractional portion of this value, unscaled.
 
uint64_t GetLow () const
 Get the fractional portion of this value, unscaled.
 
void MulByInvert (const int64x64_t &o)
 Multiply this value by a Q0.128 value, presumably representing an inverse, completing a division operation.
 
void MulByInvert (const int64x64_t &o)
 Multiply this value by a Q0.128 value, presumably representing an inverse, completing a division operation.
 
void MulByInvert (const int64x64_t &o)
 Multiply this value by a Q0.128 value, presumably representing an inverse, completing a division operation.
 
 operator bool () const
 Explicit bool conversion.
 
 operator bool () const
 Explicit bool conversion.
 
 operator bool () const
 Explicit bool conversion.
 
int64x64_toperator= (const int64x64_t &o)
 Assignment.
 
int64x64_toperator= (const int64x64_t &o)
 Assignment.
 
int64x64_toperator= (const int64x64_t &o)
 Assignment.
 
int64_t Round () const
 Round to the nearest int.
 
int64_t Round () const
 Round to the nearest int.
 
int64_t Round () const
 Round to the nearest int.
 
Construct from a floating point value.
 int64x64_t (const double value)
 Constructor from a floating point.
 
 int64x64_t (const long double value)
 Constructor from a floating point.
 
 int64x64_t (const double value)
 Constructor from a floating point.
 
 int64x64_t (const long double value)
 Constructor from a floating point.
 
 int64x64_t (double value)
 Constructor from a floating point.
 
 int64x64_t (long double value)
 Constructor from a floating point.
 
Construct from an integral type.
 int64x64_t (const int v)
 Construct from an integral type.
 
 int64x64_t (const long int v)
 Construct from an integral type.
 
 int64x64_t (const long long int v)
 Construct from an integral type.
 
 int64x64_t (const unsigned int v)
 Construct from an integral type.
 
 int64x64_t (const unsigned long int v)
 Construct from an integral type.
 
 int64x64_t (const unsigned long long int v)
 Construct from an integral type.
 
 int64x64_t (const int v)
 Construct from an integral type.
 
 int64x64_t (const long int v)
 Construct from an integral type.
 
 int64x64_t (const long long int v)
 Construct from an integral type.
 
 int64x64_t (const unsigned int v)
 Construct from an integral type.
 
 int64x64_t (const unsigned long int v)
 Construct from an integral type.
 
 int64x64_t (const unsigned long long int v)
 Construct from an integral type.
 
 int64x64_t (int v)
 Construct from an integral type.
 
 int64x64_t (long int v)
 Construct from an integral type.
 
 int64x64_t (long long int v)
 Construct from an integral type.
 
 int64x64_t (unsigned int v)
 Construct from an integral type.
 
 int64x64_t (unsigned long int v)
 Construct from an integral type.
 
 int64x64_t (unsigned long long int v)
 Construct from an integral type.
 

Static Public Member Functions

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

Static Public Attributes

static constexpr long double HP_MAX_64 = (static_cast<uint64_t>(1) << 63) * 2.0L
 Floating point value of HP_MASK_LO + 1.
 
static enum impl_type implementation = int128_impl
 Type tag for this implementation.
 

Private Member Functions

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

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.
 
static uint128_t Udiv (const uint128_t a, const uint128_t b)
 Unsigned division of Q64.64 values.
 
static cairo_uint128_t Umul (const cairo_uint128_t a, const cairo_uint128_t b)
 Unsigned multiplication of Q64.64 values.
 
static uint128_t Umul (const uint128_t a, const 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.
 
static uint128_t UmulByInvert (const uint128_t a, const uint128_t b)
 Unsigned multiplication of Q64.64 and Q0.128 values.
 

Private Attributes

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

Static Private Attributes

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

Friends

Arithmetic Operators

Arithmetic operators for int64x64_t.

bool operator== (const int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
bool operator< (const int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
bool operator> (const int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
int64x64_toperator+= (int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
int64x64_toperator-= (int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
int64x64_toperator*= (int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
int64x64_toperator/= (int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
bool operator== (const int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
bool operator< (const int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
bool operator> (const int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
int64x64_toperator+= (int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
int64x64_toperator-= (int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
int64x64_toperator*= (int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
int64x64_toperator/= (int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
bool operator== (const int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
bool operator< (const int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
bool operator> (const int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
int64x64_toperator+= (int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
int64x64_toperator-= (int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
int64x64_toperator*= (int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
int64x64_toperator/= (int64x64_t &lhs, const int64x64_t &rhs)
 Arithmetic operator.
 
Unary Operators

Unary operators for int64x64_t.

int64x64_t operator+ (const int64x64_t &lhs)
 Unary operator.
 
int64x64_t operator- (const int64x64_t &lhs)
 Unary operator.
 
int64x64_t operator! (const int64x64_t &lhs)
 Unary operator.
 
int64x64_t operator+ (const int64x64_t &lhs)
 Unary operator.
 
int64x64_t operator- (const int64x64_t &lhs)
 Unary operator.
 
int64x64_t operator! (const int64x64_t &lhs)
 Unary operator.
 
int64x64_t operator+ (const int64x64_t &lhs)
 Unary operator.
 
int64x64_t operator- (const int64x64_t &lhs)
 Unary operator.
 
int64x64_t operator! (const int64x64_t &lhs)
 Unary operator.
 

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 33 of file int64x64-double.h.

Member Enumeration Documentation

◆ impl_type [1/3]

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 63 of file int64x64-128.h.

◆ impl_type [2/3]

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 50 of file int64x64-cairo.h.

◆ impl_type [3/3]

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 49 of file int64x64-double.h.

Constructor & Destructor Documentation

◆ int64x64_t() [1/33]

ns3::int64x64_t::int64x64_t ( )
inline

Default constructor.

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

◆ int64x64_t() [2/33]

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

Constructor from a floating point.

Parameters
[in]valueFloating value to represent.

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

References _v.

◆ int64x64_t() [3/33]

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

Constructor from a floating point.

Parameters
[in]valueFloating value to represent.

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

References _v, and HP_MAX_64.

◆ int64x64_t() [4/33]

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

Construct from an integral type.

Parameters
[in]vInteger value to represent.

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

References _v.

◆ int64x64_t() [5/33]

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

Construct from an integral type.

Parameters
[in]vInteger value to represent.

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

References _v.

◆ int64x64_t() [6/33]

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 146 of file int64x64-128.h.

References _v.

◆ int64x64_t() [7/33]

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

Construct from an integral type.

Parameters
[in]vInteger value to represent.

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

References _v.

◆ int64x64_t() [8/33]

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 158 of file int64x64-128.h.

References _v.

◆ int64x64_t() [9/33]

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 164 of file int64x64-128.h.

References _v.

◆ int64x64_t() [10/33]

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 178 of file int64x64-128.h.

References _v.

◆ int64x64_t() [11/33]

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

Copy constructor.

Parameters
[in]oValue to copy.

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

◆ int64x64_t() [12/33]

ns3::int64x64_t::int64x64_t ( )
inline

Default constructor.

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

References _v.

◆ int64x64_t() [13/33]

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

Constructor from a floating point.

Parameters
[in]valueFloating value to represent.

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

References _v.

◆ int64x64_t() [14/33]

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

Constructor from a floating point.

Parameters
[in]valueFloating value to represent.

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

References _cairo_int128_negate, _v, and HP_MAX_64.

◆ int64x64_t() [15/33]

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

Construct from an integral type.

Parameters
[in]vInteger value to represent

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

References _v.

◆ int64x64_t() [16/33]

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

Construct from an integral type.

Parameters
[in]vInteger value to represent.

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

References _v.

◆ int64x64_t() [17/33]

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 134 of file int64x64-cairo.h.

References _v.

◆ int64x64_t() [18/33]

ns3::int64x64_t::int64x64_t ( const unsigned 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.

◆ int64x64_t() [19/33]

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 146 of file int64x64-cairo.h.

References _v.

◆ int64x64_t() [20/33]

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 152 of file int64x64-cairo.h.

References _v.

◆ int64x64_t() [21/33]

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 165 of file int64x64-cairo.h.

References _v.

◆ int64x64_t() [22/33]

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

Copy constructor.

Parameters
[in]oValue to copy.

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

◆ int64x64_t() [23/33]

ns3::int64x64_t::int64x64_t ( )
inline

Default constructor.

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

◆ int64x64_t() [24/33]

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

Constructor from a floating point.

Parameters
[in]valueFloating value to represent.

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

◆ int64x64_t() [25/33]

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

Constructor from a floating point.

Parameters
[in]valueFloating value to represent.

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

◆ int64x64_t() [26/33]

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

Construct from an integral type.

Parameters
[in]vInteger value to represent

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

◆ int64x64_t() [27/33]

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

Construct from an integral type.

Parameters
[in]vInteger value to represent.

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

◆ int64x64_t() [28/33]

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

Construct from an integral type.

Parameters
[in]vInteger value to represent.

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

◆ int64x64_t() [29/33]

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

Construct from an integral type.

Parameters
[in]vInteger value to represent.

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

◆ int64x64_t() [30/33]

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

Construct from an integral type.

Parameters
[in]vInteger value to represent.

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

◆ int64x64_t() [31/33]

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 120 of file int64x64-double.h.

◆ int64x64_t() [32/33]

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 132 of file int64x64-double.h.

References _v, and HP_MAX_64.

◆ int64x64_t() [33/33]

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

Copy constructor.

Parameters
[in]oValue to copy.

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

Member Function Documentation

◆ Div() [1/2]

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

Implement /=.

Parameters
[in]oThe divisor.

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

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

+ Here is the call graph for this function:

◆ Div() [2/2]

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

Implement /=.

Parameters
[in]oThe divisor.

◆ GetDouble() [1/3]

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

Get this value as a double.

Returns
This value in floating form.

Definition at line 217 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(), ns3::ShowProgress::GiveFeedback(), ns3::tests::TrickleTimerTestCase::TestSteadyState(), and ns3::Time::ToDouble().

+ Here is the caller graph for this function:

◆ GetDouble() [2/3]

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

Get this value as a double.

Returns
This value in floating form.

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

References _cairo_int128_negate, _cairo_int128_negative, _v, and HP_MAX_64.

◆ GetDouble() [3/3]

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

Get this value as a double.

Returns
This value in floating form.

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

References _v.

◆ GetHigh() [1/3]

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

Get the integer portion.

Returns
The integer portion of this value.

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

References _v.

Referenced by ns3::OnOffApplication::CancelEvents(), anonymous_namespace{sample-show-progress.cc}::Hold::Event(), Invert(), and ns3::operator<<().

+ Here is the caller graph for this function:

◆ GetHigh() [2/3]

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

Get the integer portion.

Returns
The integer portion of this value.

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

References _v.

◆ GetHigh() [3/3]

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

Get the integer portion.

Returns
The integer portion of this value.

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

References GetHighLow().

+ Here is the call graph for this function:

◆ GetHighLow()

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

Get the high and low portions of this value.

Returns
A pair of the high and low words

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

References _v, and HP_MAX_64.

Referenced by GetHigh(), and GetLow().

+ Here is the caller graph for this function:

◆ GetInt() [1/3]

int64_t ns3::int64x64_t::GetInt ( ) const
inline

Truncate to an integer.

Truncation is always toward zero,

Returns
The value truncated toward zero.

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

References _v.

◆ GetInt() [2/3]

int64_t ns3::int64x64_t::GetInt ( ) const
inline

Truncate to an integer.

Truncation is always toward zero,

Returns
The value truncated toward zero.

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

References _cairo_int128_negate, _cairo_int128_negative, and _v.

◆ GetInt() [3/3]

int64_t ns3::int64x64_t::GetInt ( ) const
inline

Truncate to an integer.

Truncation is always toward zero,

Returns
The value truncated toward zero.

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

References _v.

◆ GetLow() [1/3]

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

Get the fractional portion of this value, unscaled.

Returns
The fractional portion, unscaled, as an integer.

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

References _v, and HP_MASK_LO.

Referenced by ns3::operator<<(), and ns3::ReadLoDigits().

+ Here is the caller graph for this function:

◆ GetLow() [2/3]

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

Get the fractional portion of this value, unscaled.

Returns
The fractional portion, unscaled, as an integer.

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

References _v.

◆ GetLow() [3/3]

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

Get the fractional portion of this value, unscaled.

Returns
The fractional portion, unscaled, as an integer.

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

References GetHighLow().

+ Here is the call graph for this function:

◆ Invert() [1/3]

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 228 of file int64x64-128.cc.

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Invert() [2/3]

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 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.

◆ Invert() [3/3]

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 287 of file int64x64-double.h.

◆ Mul() [1/2]

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

Implement *=.

We assert if the product cannot be encoded in int64x64_t.

Parameters
[in]oThe other factor.

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

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

+ Here is the call graph for this function:

◆ Mul() [2/2]

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

Implement *=.

Parameters
[in]oThe other factor.

◆ MulByInvert() [1/3]

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 193 of file int64x64-128.cc.

References _v, and UmulByInvert().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MulByInvert() [2/3]

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

◆ MulByInvert() [3/3]

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 276 of file int64x64-double.h.

References _v.

◆ operator bool() [1/3]

ns3::int64x64_t::operator bool ( ) const
inlineexplicit

Explicit bool conversion.

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

References _v.

◆ operator bool() [2/3]

ns3::int64x64_t::operator bool ( ) const
inlineexplicit

Explicit bool conversion.

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

References _v.

◆ operator bool() [3/3]

ns3::int64x64_t::operator bool ( ) const
inlineexplicit

Explicit bool conversion.

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

References _v.

◆ operator=() [1/3]

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 200 of file int64x64-128.h.

References _v.

◆ operator=() [2/3]

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

Assignment.

Parameters
[in]oValue to assign to this int64x64_t.
Returns
a copy of o

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

References _v.

◆ operator=() [3/3]

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

Assignment.

Parameters
[in]oValue to assign to this int64x64_t.
Returns
a copy of o

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

References _v.

◆ Round() [1/3]

int64_t ns3::int64x64_t::Round ( ) const
inline

Round to the nearest int.

Similar to std::round this rounds halfway cases away from zero, regardless of the current (floating) rounding mode.

Returns
The value rounded to the nearest int.

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

References _v.

◆ Round() [2/3]

int64_t ns3::int64x64_t::Round ( ) const
inline

Round to the nearest int.

Similar to std::round this rounds halfway cases away from zero, regardless of the current (floating) rounding mode.

Returns
The value rounded to the nearest int.

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

References _cairo_int128_negate, _cairo_int128_negative, _cairo_uint128_add(), and _v.

+ Here is the call graph for this function:

◆ Round() [3/3]

int64_t ns3::int64x64_t::Round ( ) const
inline

Round to the nearest int.

Similar to std::round this rounds halfway cases away from zero, regardless of the current (floating) rounding mode.

Returns
The value rounded to the nearest int.

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

References _v.

◆ Udiv() [1/2]

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 121 of file int64x64-cairo.cc.

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

+ Here is the call graph for this function:

◆ Udiv() [2/2]

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 128 of file int64x64-128.cc.

References HP128_MASK_HI_BIT, and NS_ASSERT_MSG.

Referenced by Div(), and Invert().

+ Here is the caller graph for this function:

◆ Umul() [1/2]

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 76 of file int64x64-cairo.cc.

References _cairo_uint128_add(), _cairo_uint128_lsl(), _cairo_uint64_to_uint128(), _cairo_uint64x64_128_mul(), and NS_ABORT_MSG_IF.

+ Here is the call graph for this function:

◆ Umul() [2/2]

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 might assert if the result, in uint128_t format, exceeds 2^127.

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 70 of file int64x64-128.cc.

References HP_MASK_LO, and NS_ASSERT_MSG.

Referenced by Mul().

+ Here is the caller graph for this function:

◆ UmulByInvert() [1/2]

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 194 of file int64x64-cairo.cc.

References _cairo_uint128_add(), and _cairo_uint64x64_128_mul().

+ Here is the call graph for this function:

◆ UmulByInvert() [2/2]

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 203 of file int64x64-128.cc.

References HP128_MASK_HI_BIT, HP_MASK_LO, and NS_ASSERT.

Referenced by MulByInvert().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator! [1/3]

int64x64_t operator! ( const int64x64_t & lhs)
friend

Unary operator.

Parameters
[in]lhsLeft hand argument
Returns
The result of the operator.

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

◆ operator! [2/3]

int64x64_t operator! ( const int64x64_t & lhs)
friend

Unary operator.

Parameters
[in]lhsLeft hand argument
Returns
The result of the operator.

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

◆ operator! [3/3]

int64x64_t operator! ( const int64x64_t & lhs)
friend

Unary operator.

Parameters
[in]lhsLeft hand argument
Returns
The result of the operator.

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

◆ operator*= [1/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator*= [2/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator*= [3/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator+ [1/3]

int64x64_t operator+ ( const int64x64_t & lhs)
friend

Unary operator.

Parameters
[in]lhsLeft hand argument
Returns
The result of the operator.

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

◆ operator+ [2/3]

int64x64_t operator+ ( const int64x64_t & lhs)
friend

Unary operator.

Parameters
[in]lhsLeft hand argument
Returns
The result of the operator.

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

◆ operator+ [3/3]

int64x64_t operator+ ( const int64x64_t & lhs)
friend

Unary operator.

Parameters
[in]lhsLeft hand argument
Returns
The result of the operator.

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

◆ operator+= [1/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator+= [2/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator+= [3/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator- [1/3]

int64x64_t operator- ( const int64x64_t & lhs)
friend

Unary operator.

Parameters
[in]lhsLeft hand argument
Returns
The result of the operator.

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

◆ operator- [2/3]

int64x64_t operator- ( const int64x64_t & lhs)
friend

Unary operator.

Parameters
[in]lhsLeft hand argument
Returns
The result of the operator.

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

◆ operator- [3/3]

int64x64_t operator- ( const int64x64_t & lhs)
friend

Unary operator.

Parameters
[in]lhsLeft hand argument
Returns
The result of the operator.

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

◆ operator-= [1/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator-= [2/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator-= [3/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator/= [1/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator/= [2/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator/= [3/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator< [1/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator< [2/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator< [3/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator== [1/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator== [2/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator== [3/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator> [1/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator> [2/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

◆ operator> [3/3]

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

Arithmetic operator.

Parameters
[in]lhsLeft hand argument
[in]rhsRight hand argument
Returns
The result of the operator.

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

Member Data Documentation

◆ _v [1/3]

◆ _v [2/3]

cairo_int128_t ns3::int64x64_t::_v
private

The Q64.64 value.

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

◆ _v [3/3]

long double ns3::int64x64_t::_v
private

The Q64.64 value.

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

◆ HP128_MASK_HI_BIT

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 Mul(), Udiv(), and UmulByInvert().

◆ HP_MASK_LO

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().

◆ HP_MAX_64

static constexpr long double ns3::int64x64_t::HP_MAX_64 = (static_cast<uint64_t>(1) << 63) * 2.0L
staticconstexpr

Floating point value of HP_MASK_LO + 1.

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

Referenced by int64x64_t(), int64x64_t(), ns3::int64x64::test::Int64x64HiLoTestCase::DoRun(), GetDouble(), and GetHighLow().

◆ HPCAIRO_MASK_HI_BIT

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

High bit of fractional part.

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

Referenced by Udiv().

◆ implementation


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