Browse Source

Util: Reset IOstreams flags after usage

master
Riyyi 2 years ago
parent
commit
15a524adbb
  1. 14
      src/util/format/builder.cpp

14
src/util/format/builder.cpp

@ -6,7 +6,7 @@
#include <cstddef> // size_t #include <cstddef> // size_t
#include <iomanip> // setprecision #include <iomanip> // setprecision
#include <ios> // fixed #include <ios> // defaultfloat, fixed
#include <limits> // numeric_limits #include <limits> // numeric_limits
#include <sstream> // stringstream #include <sstream> // stringstream
#include <string> #include <string>
@ -32,9 +32,9 @@ void Builder::putF32(float number, size_t precision) const
std::stringstream stream; std::stringstream stream;
stream stream
<< std::fixed << std::fixed << std::setprecision(precision)
<< std::setprecision(precision) << number
<< number; << std::defaultfloat << std::setprecision(6);
std::string string = stream.str(); std::string string = stream.str();
string = string.substr(0, string.find_first_of('0', string.find('.'))); string = string.substr(0, string.find_first_of('0', string.find('.')));
m_builder << string; m_builder << string;
@ -46,9 +46,9 @@ void Builder::putF64(double number, size_t precision) const
std::stringstream stream; std::stringstream stream;
stream stream
<< std::fixed << std::fixed << std::setprecision(precision)
<< std::setprecision(precision) << number
<< number; << std::defaultfloat << std::setprecision(6);
std::string string = stream.str(); std::string string = stream.str();
string = string.substr(0, string.find_first_of('0', string.find('.'))); string = string.substr(0, string.find_first_of('0', string.find('.')));
m_builder << string; m_builder << string;

Loading…
Cancel
Save