40#define HEXHILOW(hi, lo) \
41 std::hex << std::setfill('0') << std::right << " (0x" << std::setw(16) << hi << " " \
42 << std::setw(16) << lo << std::dec << std::setfill(' ') << std::left << ")"
60 const bool negative = (value < 0);
64 if (value !=
int64x64_t(std::numeric_limits<int64_t>::min(), 0))
66 const int64x64_t absVal = (negative ? -value : value);
72 hi =
static_cast<uint64_t
>(1) << 63;
76 auto precision =
static_cast<std::size_t
>(os.precision());
77 std::ios_base::fmtflags ff = os.flags();
78 const bool floatfield = os.flags() & std::ios_base::floatfield;
79 os << std::setw(1) << std::noshowpos;
81 os << std::right << (negative ?
"-" :
"+");
83 std::ostringstream oss;
86 std::size_t places = 0;
90 << (floatfield ?
" f" :
" ") <<
"[" << precision <<
"] " << hi <<
". "
99 "digit " << digit <<
" out of range [0,9] "
100 <<
" streaming out " <<
HEXHILOW(value.GetHigh(), value.GetLow()));
103 oss << std::setw(1) << digit;
108 more = places < precision;
113 more = low.
GetLow() && (places < 20);
116 NS_LOG_LOGIC((more ?
"+" :
" ") << (floatfield ?
"f" :
" ") <<
"[" << places <<
"] "
118 << std::dec << std::setfill(
' ') << std::left);
124 std::string digits = oss.str();
126 int64_t nextDigit = low.
GetHigh();
127 if ((nextDigit > 5) || ((nextDigit == 5) && (digit % 2 == 1)))
131 for (std::string::reverse_iterator rit = digits.rbegin(); rit != digits.rend(); ++rit)
151 digits.insert(digits.begin(),
'1');
172 const char* buf = str.c_str();
177 retval += *buf -
'0';
199 for (std::string::const_reverse_iterator rit = str.rbegin(); rit != str.rend(); ++rit)
201 int digit = *rit -
'0';
203 "digit " << digit <<
" out of range [0,9]"
204 <<
" streaming in low digits \"" << str <<
"\"");
205 low = (low + digit + round) / 10;
219 std::string::size_type cur;
220 cur = str.find_first_not_of(
' ');
221 std::string::size_type next;
223 next = str.find(
'-', cur);
224 if (next != std::string::npos)
231 next = str.find(
'+', cur);
232 if (next != std::string::npos)
245 next = str.find(
'.', cur);
246 if (next != std::string::npos)
249 lo =
ReadLoDigits(str.substr(next + 1, str.size() - (next + 1)));
251 else if (cur != std::string::npos)
263 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.