51 const bool negative = (value < 0);
52 const int64x64_t absVal = (negative ? -value : value);
57 const std::streamsize precision = os.precision ();
58 std::ios_base::fmtflags ff = os.flags ();
59 const bool floatfield = os.flags () & std::ios_base::floatfield;
60 os << std::setw (1) << std::noshowpos;
62 os << std::right << (negative ?
"-" :
"+");
64 std::ostringstream oss;
72 #define HEXHILOW(hi, lo) \
73 std::hex << std::setfill ('0') << std::right << " (0x" \
74 << std::setw (16) << hi << " " \
75 << std::setw (16) << lo \
76 << std::dec << std::setfill (' ') << std::left << ")"
80 << (floatfield ?
" f" :
" ")
81 <<
"[" << precision <<
"] " << hi <<
". "
89 digit = low.GetHigh ();
91 "digit " << digit <<
" out of range [0,9] "
96 oss << std::setw (1) << digit;
101 more = places < precision;
106 more = low.GetLow () && (places < 20);
110 << (floatfield ?
"f" :
" ")
111 <<
"[" << places <<
"] " << digit
112 <<
HEXHILOW (low.GetHigh (), low.GetLow ())
113 << std::dec << std::setfill (
' ' ) << std::left);
119 std::string digits = oss.str ();
121 int64_t nextDigit = low.GetHigh ();
122 if ( (nextDigit > 5) || ((nextDigit == 5) && (digit % 2 == 1)) )
126 for (std::string::reverse_iterator rit = digits.rbegin ();
127 rit != digits.rend ();
148 digits.insert (digits.begin (),
'1');
168 const char *buf = str.c_str ();
173 retval += *buf -
'0';
194 for (std::string::const_reverse_iterator rit = str.rbegin ();
198 int digit = *rit -
'0';
200 "digit " << digit <<
" out of range [0,9]"
201 <<
" streaming in low digits \"" << str <<
"\"");
202 low = (low + digit + round) / 10;
215 std::string::size_type cur;
216 cur = str.find_first_not_of (
" ");
217 std::string::size_type next;
219 next = str.find (
"-", cur);
220 if (next != std::string::npos)
227 next = str.find (
"+", cur);
228 if (next != std::string::npos)
241 next = str.find (
".", cur);
242 if (next != std::string::npos)
245 lo =
ReadLoDigits (str.substr (next+1, str.size ()-(next+1)));
247 else if (cur != std::string::npos)
259 value = negative ? -value : value;
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
uint64_t GetLow(void) const
Get the fractional portion of this value, unscaled.
High precision numerical type, implementing Q64.64 fixed precision.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
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...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
int64_t GetHigh(void) const
Get the integer portion.