Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86507 - trunk/boost/archive
From: ramey_at_[hidden]
Date: 2013-10-28 17:38:15


Author: ramey
Date: 2013-10-28 17:38:15 EDT (Mon, 28 Oct 2013)
New Revision: 86507
URL: http://svn.boost.org/trac/boost/changeset/86507

Log:
corrected # digits - next attempt

Text files modified:
   trunk/boost/archive/basic_text_oprimitive.hpp | 15 +++++++++++----
   1 files changed, 11 insertions(+), 4 deletions(-)

Modified: trunk/boost/archive/basic_text_oprimitive.hpp
==============================================================================
--- trunk/boost/archive/basic_text_oprimitive.hpp Mon Oct 28 16:32:52 2013 (r86506)
+++ trunk/boost/archive/basic_text_oprimitive.hpp 2013-10-28 17:38:15 EDT (Mon, 28 Oct 2013) (r86507)
@@ -26,13 +26,14 @@
 
 #include <iomanip>
 #include <locale>
-//#include <boost/config/no_tr1/cmath.hpp> // isnan
 #include <boost/assert.hpp>
 #include <cstddef> // size_t
 
 #include <boost/config.hpp>
 #include <boost/static_assert.hpp>
 #include <boost/detail/workaround.hpp>
+#include <boost/io/ios_state.hpp>
+
 #if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
 #include <boost/archive/dinkumware.hpp>
 #endif
@@ -136,7 +137,7 @@
     // we'll get a compile time error. This is meant to automatically
     // support synthesized types which support floating point
     // operations. Also it should handle compiler dependent types
- // such long double. Due to John Maddoc.
+ // such long double. Due to John Maddock.
 
     template<class T>
     struct is_float {
@@ -159,16 +160,22 @@
         // The formulae for the number of decimla digits required is given in
         // http://www2.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1822.pdf
         // which is derived from Kahan's paper:
- // http://http.cs.berkley.edu/~wkahan/ieee754status/ieee754.ps
+ // www.eecs.berkeley.edu/~wkahan/ieee754status/ieee754.ps
         // const unsigned int digits = (std::numeric_limits<T>::digits * 3010) / 10000;
         // note: I've commented out the above because I didn't get good results. e.g.
         // in one case I got a difference of 19 units.
- const unsigned int digits = std::numeric_limits<T>::digits10 + 2;
+ #ifndef BOOST_NO_CXX11_NUMERIC_LIMITS
+ const unsigned int digits = std::numeric_limits<T>::max_digits10;
+ #else
+ const unsigned int digits = std::numeric_limits<T>::digits10 + 2;
+ #endif
         os << std::setprecision(digits) << std::scientific << t;
     }
 
     template<class T>
     void save(const T & t){
+ boost::io::ios_flags_saver fs(os);
+ boost::io::ios_precision_saver ps(os);
         BOOST_DEDUCED_TYPENAME is_float<T>::type tf;
         save_impl(t, tf);
     }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk