A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
High Precision Q64.64

Functions and class for high precision Q64.64 fixed point arithmetic. More...

+ Collaboration diagram for High Precision Q64.64:

Classes

class  ns3::int64x64_t
 High precision numerical type, implementing Q64.64 fixed precision. More...
 

Functions

int64x64_t ns3::Abs (const int64x64_t &value)
 Absolute value. More...
 
int64x64_t ns3::Max (const int64x64_t &a, const int64x64_t &b)
 Maximum. More...
 
int64x64_t ns3::Min (const int64x64_t &a, const int64x64_t &b)
 Minimum. More...
 
int64x64_t ns3::operator! (const int64x64_t &lhs)
 Logical not operator. More...
 
bool ns3::operator!= (const int64x64_t &lhs, const int64x64_t &rhs)
 Inequality operator. More...
 
int64x64_t ns3::operator* (const int64x64_t &lhs, const int64x64_t &rhs)
 Multiplication operator. More...
 
int64x64_t & ns3::operator*= (int64x64_t &lhs, const int64x64_t &rhs)
 Compound multiplication operator. More...
 
int64x64_t ns3::operator+ (const int64x64_t &lhs, const int64x64_t &rhs)
 Addition operator. More...
 
int64x64_t ns3::operator+ (const int64x64_t &lhs)
 Unary plus operator. More...
 
int64x64_t & ns3::operator+= (int64x64_t &lhs, const int64x64_t &rhs)
 Compound addition operator. More...
 
int64x64_t ns3::operator- (const int64x64_t &lhs, const int64x64_t &rhs)
 Subtraction operator. More...
 
int64x64_t ns3::operator- (const int64x64_t &lhs)
 Unary negation operator (change sign operator) More...
 
int64x64_t & ns3::operator-= (int64x64_t &lhs, const int64x64_t &rhs)
 Compound subtraction operator. More...
 
int64x64_t ns3::operator/ (const int64x64_t &lhs, const int64x64_t &rhs)
 Division operator. More...
 
int64x64_t & ns3::operator/= (int64x64_t &lhs, const int64x64_t &rhs)
 Compound division operator. More...
 
bool ns3::operator< (const int64x64_t &lhs, const int64x64_t &rhs)
 Less than operator. More...
 
std::ostream & ns3::operator<< (std::ostream &os, const int64x64_t &val)
 Output streamer for int64x64_t. More...
 
bool ns3::operator<= (const int64x64_t &lhs, const int64x64_t &rhs)
 Less or equal operator. More...
 
bool ns3::operator== (const int64x64_t &lhs, const int64x64_t &rhs)
 Equality operator. More...
 
bool ns3::operator> (const int64x64_t &lhs, const int64x64_t &rhs)
 Greater operator. More...
 
bool ns3::operator>= (const int64x64_t &lhs, const int64x64_t &rhs)
 Greater or equal operator. More...
 
std::istream & ns3::operator>> (std::istream &is, int64x64_t &val)
 Input streamer for int64x64_t. More...
 

Detailed Description

Functions and class for high precision Q64.64 fixed point arithmetic.

Function Documentation

int64x64_t ns3::Min ( const int64x64_t &  a,
const int64x64_t &  b 
)
inline
int64x64_t ns3::operator! ( const int64x64_t &  lhs)
inline

Logical not operator.

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

References ns3::int64x64_t::_v.

bool ns3::operator!= ( const int64x64_t &  lhs,
const int64x64_t &  rhs 
)
inline

Inequality operator.

Definition at line 138 of file int64x64.h.

int64x64_t ns3::operator* ( const int64x64_t &  lhs,
const int64x64_t &  rhs 
)
inline

Multiplication operator.

Definition at line 117 of file int64x64.h.

int64x64_t& ns3::operator*= ( int64x64_t &  lhs,
const int64x64_t &  rhs 
)
inline

Compound multiplication operator.

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

References ns3::int64x64_t::Mul().

+ Here is the call graph for this function:

int64x64_t ns3::operator+ ( const int64x64_t &  lhs,
const int64x64_t &  rhs 
)
inline

Addition operator.

Definition at line 95 of file int64x64.h.

int64x64_t ns3::operator+ ( const int64x64_t &  lhs)
inline

Unary plus operator.

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

int64x64_t& ns3::operator+= ( int64x64_t &  lhs,
const int64x64_t &  rhs 
)
inline

Compound addition operator.

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

References ns3::int64x64_t::_v.

int64x64_t ns3::operator- ( const int64x64_t &  lhs,
const int64x64_t &  rhs 
)
inline

Subtraction operator.

Definition at line 106 of file int64x64.h.

int64x64_t ns3::operator- ( const int64x64_t &  lhs)
inline

Unary negation operator (change sign operator)

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

References ns3::int64x64_t::_v.

int64x64_t& ns3::operator-= ( int64x64_t &  lhs,
const int64x64_t &  rhs 
)
inline

Compound subtraction operator.

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

References ns3::int64x64_t::_v.

int64x64_t ns3::operator/ ( const int64x64_t &  lhs,
const int64x64_t &  rhs 
)
inline

Division operator.

Definition at line 128 of file int64x64.h.

int64x64_t& ns3::operator/= ( int64x64_t &  lhs,
const int64x64_t &  rhs 
)
inline

Compound division operator.

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

References ns3::int64x64_t::Div().

+ Here is the call graph for this function:

bool ns3::operator< ( const int64x64_t &  lhs,
const int64x64_t &  rhs 
)
inline

Less than operator.

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

References ns3::int64x64_t::_v.

std::ostream & ns3::operator<< ( std::ostream &  os,
const int64x64_t &  value 
)

Output streamer for int64x64_t.

Internal:
This algorithm is exact to the precision requested, up to the full 64 decimal digits required to exactly represent a 64-bit fraction.

Proper rounding turns out to be surprisingly hard. In y.xxxx5|6, where the | marks follows the last output digit, rounding the 5|6 to 6| is straightforward. However, rounding y.xxx99|6 should result in y.xx100|. Notice the effect of rounding percolates to higher digits. We accumulate the output digits in a string, then carry out the rounding in the string directly.

Values are printed with the following format flags (independent of the the stream flags):

  • showpos
  • left

The stream width is ignored. If floatfield is set, precision decimal places are printed. If floatfield is not set, all digits of the fractional part are printed, up to the representation limit of 20 digits; trailing zeros are omitted.

Definition at line 30 of file int64x64.cc.

References ns3::int64x64_t::GetHigh(), ns3::int64x64_t::GetLow(), HEXHILOW, NS_ASSERT_MSG, and NS_LOG_LOGIC.

+ Here is the call graph for this function:

bool ns3::operator<= ( const int64x64_t &  lhs,
const int64x64_t &  rhs 
)
inline

Less or equal operator.

Definition at line 146 of file int64x64.h.

bool ns3::operator== ( const int64x64_t &  lhs,
const int64x64_t &  rhs 
)
inline

Equality operator.

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

References ns3::int64x64_t::_v.

bool ns3::operator> ( const int64x64_t &  lhs,
const int64x64_t &  rhs 
)
inline

Greater operator.

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

References ns3::int64x64_t::_v.

bool ns3::operator>= ( const int64x64_t &  lhs,
const int64x64_t &  rhs 
)
inline

Greater or equal operator.

Definition at line 154 of file int64x64.h.

std::istream & ns3::operator>> ( std::istream &  is,
int64x64_t &  value 
)

Input streamer for int64x64_t.

Definition at line 170 of file int64x64.cc.

References ns3::ReadHiDigits(), and ns3::ReadLoDigits().

+ Here is the call graph for this function: