Ticket #9177: basic_text_oprimitive.hpp.2.patch
File basic_text_oprimitive.hpp.2.patch, 1.5 KB (added by , 9 years ago) |
---|
-
basic_text_oprimitive.hpp
136 136 // we'll get a compile time error. This is meant to automatically 137 137 // support synthesized types which support floating point 138 138 // operations. Also it should handle compiler dependent types 139 // such long double. Due to John Maddoc .139 // such long double. Due to John Maddock. 140 140 141 141 template<class T> 142 142 struct is_float { … … 156 156 boost::serialization::throw_exception( 157 157 archive_exception(archive_exception::output_stream_error) 158 158 ); 159 #ifndef BOOST_NO_CXX11_NUMERIC_LIMITS 160 const unsigned int digits = std::numeric_limits<T>::max_digits10; 161 #else 159 162 // The formulae for the number of decimla digits required is given in 160 163 // http://www2.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1822.pdf 161 164 // which is derived from Kahan's paper: 162 165 // http://http.cs.berkley.edu/~wkahan/ieee754status/ieee754.ps 163 const unsigned int digits = (std::numeric_limits<float>::digits * 3010) / 10000; 164 os << std::setprecision(digits); 166 const unsigned int digits = std::numeric_limits<T>::radix == 2 ? (std::numeric_limits<T>::digits * 3010) / 10000 : std::numeric_limits<T>::digits10; 167 #endif 168 os << std::setprecision(digits) << std::scientific; 165 169 os << t; 166 170 } 167 171