id summary reporter owner description type status milestone component version severity resolution keywords cc 11056 karma real generator does not produce enough digits to guarantee round trip through spirit reallyasi9@… Joel de Guzman "The real_inserter::call_n method in [http://svn.boost.org/svn/boost/trunk/boost/spirit/home/karma/numeric/detail/real_utils.hpp] limits the number of output characters representing a real (floating-point) number of type U to std::numeric_limits::digits10. However, digits10 represents the number of decimal digits that are guaranteed to survive a round-trip conversion for the type. This is not the same as the number of decimal digits that a type can represent, which is std::numeric_limits::max_digits10 (in c++11). The following code describes the problem when attempting to round-trip using karma and spirit vs. using stringstreams, picking a particular value that fails: {{{ #!c++ // define a new real number formatting policy struct precise_policy : real_policies { // Limited to digits10, no matter what I put here static unsigned int precision(float) { return std::numeric_limits::max_digits10; } }; float a = 135.477005; std::stringstream ss; ss.precision(std::numeric_limits::max_digits10); ss << a; float b; ss >> b; assert(a == b); // succeeds std::string st; typedef std::back_insert_iterator sink_type; sink_type sink(st); typedef real_generator precise_type; precise_type const precise = precise_type(); generate(sink, precise, a); float c; parse(st.begin(), st.end(), float_, c); assert(a == c); // fails, even though enough digits were requested // with precise_policy! }}} One solution would be to change the maximum number of digits to std::numeric_limits::max_digits10 (or the equivalent in non-c++11 code)." Bugs closed To Be Determined spirit Boost 1.57.0 Problem fixed karma,real_generator