32 const bool negative = (value < 0);
33 const int64x64_t absVal = (negative ? -value : value);
38 const std::streamsize precision = os.precision ();
39 std::ios_base::fmtflags ff = os.flags ();
40 const bool floatfield = os.flags () & std::ios_base::floatfield;
41 os << std::setw (1) << std::noshowpos;
43 os << std::right << (negative ?
"-" :
"+");
45 std::ostringstream oss;
53 #define HEXHILOW(hi, lo) \
54 std::hex << std::setfill ('0') << std::right << " (0x" \
55 << std::setw (16) << hi << " " \
56 << std::setw (16) << lo \
57 << std::dec << std::setfill (' ') << std::left << ")"
61 << (floatfield ?
" f" :
" ")
62 <<
"[" << precision <<
"] " << hi <<
". "
70 digit = low.GetHigh ();
72 "digit " << digit <<
" out of range [0,9] "
77 oss << std::setw (1) << digit;
82 more = places < precision;
87 more = low.GetLow () && (places < 20);
91 << (floatfield ?
"f" :
" ")
92 <<
"[" << places <<
"] " << digit
93 <<
HEXHILOW (low.GetHigh (), low.GetLow ())
94 << std::dec << std::setfill (
' ' ) << std::left);
100 std::string digits = oss.str ();
102 int64_t nextDigit = low.GetHigh ();
103 if ( (nextDigit > 5) || ((nextDigit == 5) && (digit % 2 == 1)) )
107 for (std::string::reverse_iterator rit = digits.rbegin ();
108 rit != digits.rend ();
129 digits.insert (digits.begin (),
'1');
140 const char *buf = str.c_str ();
145 retval += *buf -
'0';
156 for (std::string::const_reverse_iterator rit = str.rbegin ();
160 int digit = *rit -
'0';
162 "digit " << digit <<
" out of range [0,9]"
163 <<
" streaming in low digits \"" << str <<
"\"");
164 low = (low + digit + round) / 10;
177 std::string::size_type cur;
178 cur = str.find_first_not_of (
" ");
179 std::string::size_type next;
181 next = str.find (
"-", cur);
182 if (next != std::string::npos)
189 next = str.find (
"+", cur);
190 if (next != std::string::npos)
203 next = str.find (
".", cur);
204 if (next != std::string::npos)
207 lo =
ReadLoDigits (str.substr (next+1, str.size ()-(next+1)));
209 else if (cur != std::string::npos)
221 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.
static uint64_t ReadLoDigits(std::string str)
#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
#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.
static uint64_t ReadHiDigits(std::string str)