[Boost-bugs] [Boost C++ Libraries] #6627: nonfinite_num_put formatting of 0.0 is incorrect

Subject: [Boost-bugs] [Boost C++ Libraries] #6627: nonfinite_num_put formatting of 0.0 is incorrect
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-02-28 19:33:59


#6627: nonfinite_num_put formatting of 0.0 is incorrect
-----------------------------------------+----------------------------------
 Reporter: krwalker@… | Owner: johnmaddock
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: math
  Version: Boost 1.48.0 | Severity: Problem
 Keywords: |
-----------------------------------------+----------------------------------
 We noticed time strings changed from displaying 00:00.00 to 00:00000 after
 installing the nonfinite_num facets globally. It appears that formatting
 for 0.0 isn't behaving as it should when precision and fixed are involved
 (and potentially others).

 {{{
 #include <boost/math/special_functions/nonfinite_num_facets.hpp>
 #include <iomanip>
 #include <iostream>
 #include <sstream>

 void writeZero( std::ostream& stream ) {
   stream << std::fixed << std::setw( 5 ) << std::setfill( '0' ) <<
 std::setprecision( 2 ) << 0.0;
 }

 int main() {
   std::stringstream standardStream;
   writeZero( standardStream );
   std::cout << standardStream.str() << std::endl;

   std::stringstream nonfiniteStream;
   std::locale nonfiniteNumLocale( std::locale(), new
 boost::math::nonfinite_num_put< char >() );
   nonfiniteStream.imbue( nonfiniteNumLocale );

   writeZero( nonfiniteStream );
   std::cout << nonfiniteStream.str() << std::endl;

   return 0;
 }

 // OUTPUT:
 //
 // 00.00
 // 00000

 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6627>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC