52#define HEXHILOW(hi, lo) \
53 std::hex << std::setfill('0') << std::right << " (0x" << std::setw(16) << hi << " " \
54 << std::setw(16) << lo << std::dec << std::setfill(' ') << std::left << ")"
72 const bool negative = (value < 0);
76 if (value !=
int64x64_t(std::numeric_limits<int64_t>::min(), 0))
78 const int64x64_t absVal = (negative ? -value : value);
84 hi =
static_cast<uint64_t
>(1) << 63;
88 auto precision =
static_cast<std::size_t
>(os.precision());
89 std::ios_base::fmtflags ff = os.flags();
90 const bool floatfield = os.flags() & std::ios_base::floatfield;
91 os << std::setw(1) << std::noshowpos;
93 os << std::right << (negative ?
"-" :
"+");
95 std::ostringstream oss;
98 std::size_t places = 0;
102 << (floatfield ?
" f" :
" ") <<
"[" << precision <<
"] " << hi <<
". "
111 "digit " << digit <<
" out of range [0,9] "
112 <<
" streaming out " <<
HEXHILOW(value.GetHigh(), value.GetLow()));
115 oss << std::setw(1) << digit;
120 more = places < precision;
125 more = low.
GetLow() && (places < 20);
128 NS_LOG_LOGIC((more ?
"+" :
" ") << (floatfield ?
"f" :
" ") <<
"[" << places <<
"] "
130 << std::dec << std::setfill(
' ') << std::left);
136 std::string digits = oss.str();
138 int64_t nextDigit = low.
GetHigh();
139 if ((nextDigit > 5) || ((nextDigit == 5) && (digit % 2 == 1)))
143 for (std::string::reverse_iterator rit = digits.rbegin(); rit != digits.rend(); ++rit)
163 digits.insert(digits.begin(),
'1');
184 const char* buf = str.c_str();
189 retval += *buf -
'0';
211 for (std::string::const_reverse_iterator rit = str.rbegin(); rit != str.rend(); ++rit)
213 int digit = *rit -
'0';
215 "digit " << digit <<
" out of range [0,9]"
216 <<
" streaming in low digits \"" << str <<
"\"");
217 low = (low + digit + round) / 10;
231 std::string::size_type cur;
232 cur = str.find_first_not_of(
' ');
233 std::string::size_type next;
235 next = str.find(
'-', cur);
236 if (next != std::string::npos)
243 next = str.find(
'+', cur);
244 if (next != std::string::npos)
257 next = str.find(
'.', cur);
258 if (next != std::string::npos)
261 lo =
ReadLoDigits(str.substr(next + 1, str.size() - (next + 1)));
263 else if (cur != std::string::npos)
275 value = negative ? -value : value;
NS_ASSERT() and NS_ASSERT_MSG() macro definitions.
High precision numerical type, implementing Q64.64 fixed precision.
int64_t GetHigh() const
Get the integer portion.
uint64_t GetLow() const
Get the fractional portion of this value, unscaled.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
static uint64_t ReadHiDigits(std::string str)
Read the integer portion of a number from a string containing just the integral digits (no decimal po...
#define HEXHILOW(hi, lo)
Print the high and low words of an int64x64 in hex, for debugging.
static uint64_t ReadLoDigits(std::string str)
Read the fractional part of a number from a string containing just the decimal digits of the fraction...
#define NS_LOG_COMPONENT_DEFINE_MASK(name, mask)
Define a logging component with a mask.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Declaration of the ns3::int64x64_t type and associated operators.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
std::istream & operator>>(std::istream &is, Angles &a)
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.