57 const bool negative = (value < 0);
58 const int64x64_t absVal = (negative ? -value : value);
63 const std::streamsize precision = os.precision ();
64 std::ios_base::fmtflags ff = os.flags ();
65 const bool floatfield = os.flags () & std::ios_base::floatfield;
66 os << std::setw (1) << std::noshowpos;
68 os << std::right << (negative ?
"-" :
"+");
70 std::ostringstream oss;
78 #define HEXHILOW(hi, lo) \
79 std::hex << std::setfill ('0') << std::right << " (0x" \
80 << std::setw (16) << hi << " " \
81 << std::setw (16) << lo \
82 << std::dec << std::setfill (' ') << std::left << ")"
86 << (floatfield ?
" f" :
" ")
87 <<
"[" << precision <<
"] " << hi <<
". "
95 digit = low.GetHigh ();
97 "digit " << digit <<
" out of range [0,9] "
102 oss << std::setw (1) << digit;
107 more = places < precision;
112 more = low.GetLow () && (places < 20);
116 << (floatfield ?
"f" :
" ")
117 <<
"[" << places <<
"] " << digit
118 <<
HEXHILOW (low.GetHigh (), low.GetLow ())
119 << std::dec << std::setfill (
' ' ) << std::left);
125 std::string digits = oss.str ();
127 int64_t nextDigit = low.GetHigh ();
128 if ( (nextDigit > 5) || ((nextDigit == 5) && (digit % 2 == 1)) )
132 for (std::string::reverse_iterator rit = digits.rbegin ();
133 rit != digits.rend ();
154 digits.insert (digits.begin (),
'1');
174 const char *buf = str.c_str ();
179 retval += *buf -
'0';
200 for (std::string::const_reverse_iterator rit = str.rbegin ();
204 int digit = *rit -
'0';
206 "digit " << digit <<
" out of range [0,9]"
207 <<
" streaming in low digits \"" << str <<
"\"");
208 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;
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.
Definition of assertion macros NS_ASSERT() and NS_ASSERT_MSG().
#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.
Declaration of the ns3::int64x64_t type and associated operators.