49 #define HEXHILOW(hi, lo) \
50 std::hex << std::setfill ('0') << std::right << " (0x" \
51 << std::setw (16) << hi << " " \
52 << std::setw (16) << lo \
53 << std::dec << std::setfill (' ') << std::left << ")"
71 const bool negative = (value < 0);
72 const int64x64_t absVal = (negative ? -value : value);
77 std::size_t 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;
89 std::size_t places = 0;
93 << (floatfield ?
" f" :
" ")
94 <<
"[" << precision <<
"] " << hi <<
". "
104 "digit " << digit <<
" out of range [0,9] " <<
106 HEXHILOW (value.GetHigh (), value.GetLow ()) );
109 oss << std::setw (1) << digit;
114 more = places < precision;
119 more = low.
GetLow () && (places < 20);
123 << (floatfield ?
"f" :
" ")
124 <<
"[" << places <<
"] " << digit
126 << std::dec << std::setfill (
' ' ) << std::left);
133 std::string digits = oss.str ();
135 int64_t nextDigit = low.
GetHigh ();
136 if ( (nextDigit > 5) || ((nextDigit == 5) && (digit % 2 == 1)) )
140 for (std::string::reverse_iterator rit = digits.rbegin ();
141 rit != digits.rend ();
162 digits.insert (digits.begin (),
'1');
182 const char *buf = str.c_str ();
187 retval += *buf -
'0';
208 for (std::string::const_reverse_iterator rit = str.rbegin ();
212 int digit = *rit -
'0';
214 "digit " << digit <<
" out of range [0,9]" <<
215 " streaming in low digits \"" << str <<
"\"");
216 low = (low + digit + round) / 10;
229 std::string::size_type cur;
230 cur = str.find_first_not_of (
" ");
231 std::string::size_type next;
233 next = str.find (
"-", cur);
234 if (next != std::string::npos)
241 next = str.find (
"+", cur);
242 if (next != std::string::npos)
255 next = str.find (
".", cur);
256 if (next != std::string::npos)
259 lo =
ReadLoDigits (str.substr (next + 1, str.size () - (next + 1)));
261 else if (cur != std::string::npos)
263 hi =
ReadHiDigits (str.substr (cur, str.size () - cur));
273 value = negative ? -value : value;
NS_ASSERT() and NS_ASSERT_MSG() macro definitions.
High precision numerical type, implementing Q64.64 fixed precision.
int64_t GetHigh(void) const
Get the integer portion.
uint64_t GetLow(void) 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)