51 #define HEXHILOW(hi, lo) \
52 std::hex << std::setfill('0') << std::right << " (0x" << std::setw(16) << hi << " " \
53 << std::setw(16) << lo << std::dec << std::setfill(' ') << std::left << ")"
71 const bool negative = (value < 0);
72 const int64x64_t absVal = (negative ? -value : value);
77 auto precision =
static_cast<std::size_t
>(os.precision());
78 std::ios_base::fmtflags ff = os.flags();
79 const bool floatfield = os.flags() & std::ios_base::floatfield;
80 os << std::setw(1) << std::noshowpos;
82 os << std::right << (negative ?
"-" :
"+");
84 std::ostringstream oss;
88 std::size_t places = 0;
92 << (floatfield ?
" f" :
" ") <<
"[" << precision <<
"] " << hi <<
". "
101 "digit " << digit <<
" out of range [0,9] "
102 <<
" streaming out " <<
HEXHILOW(value.GetHigh(), value.GetLow()));
105 oss << std::setw(1) << digit;
110 more = places < precision;
115 more = low.
GetLow() && (places < 20);
118 NS_LOG_LOGIC((more ?
"+" :
" ") << (floatfield ?
"f" :
" ") <<
"[" << places <<
"] "
120 << std::dec << std::setfill(
' ') << std::left);
126 std::string digits = oss.str();
128 int64_t nextDigit = low.
GetHigh();
129 if ((nextDigit > 5) || ((nextDigit == 5) && (digit % 2 == 1)))
133 for (std::string::reverse_iterator rit = digits.rbegin(); rit != digits.rend(); ++rit)
153 digits.insert(digits.begin(),
'1');
174 const char* buf = str.c_str();
179 retval += *buf -
'0';
201 for (std::string::const_reverse_iterator rit = str.rbegin(); rit != str.rend(); ++rit)
203 int digit = *rit -
'0';
205 "digit " << digit <<
" out of range [0,9]"
206 <<
" streaming in low digits \"" << str <<
"\"");
207 low = (low + digit + round) / 10;
221 std::string::size_type cur;
222 cur = str.find_first_not_of(
' ');
223 std::string::size_type next;
225 next = str.find(
'-', cur);
226 if (next != std::string::npos)
233 next = str.find(
'+', cur);
234 if (next != std::string::npos)
247 next = str.find(
'.', cur);
248 if (next != std::string::npos)
251 lo =
ReadLoDigits(str.substr(next + 1, str.size() - (next + 1)));
253 else if (cur != std::string::npos)
265 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.
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
std::istream & operator>>(std::istream &is, Angles &a)
std::ostream & operator<<(std::ostream &os, const Angles &a)