------- Additional Comments From stefan dot becuwe at ua dot ac dot be  
2005-07-18 09:30 -------
(In reply to comment #2)
> Well, certainly, this is not a libstdc++-v3 bug: internally we are simply 
> printing floating point numbers using sprintf (or snprintf, when available), 
> as
> mandated by the standard. Actually, however, I'm not at all sure what's the
> point of your report: you are changing the rounding mode for floating point
> operations, but in the testcase there aren't: there is only the definition of
> p (taking place *before* any setround)

Ok, I'll reformulate it and I've even simplified the input.  4.5 is exactly
representable in double precision, regardless of the active rounding precision.
 It should always be 4.5.  What I would like to do is to have that double
precision input rounded to the number of digits given by .precision (1 in the
example) using stringstreams, taking into account the rounding mode.  In the
following example, I assign a value to p AFTER setting the rounding mode.  And
guess, for the 4 rounding modes I now get 4 instead 5 (in my original post). 
Although internally the value of p should be 4.5...  Again: two of the four
cases are wrong...  So, as far as I'm concerned, I still think there's an error
somewhere.


  s1.setf(ios::scientific, ios::floatfield);
  s1.setf(ios::showpoint, ios::floatfield);
  s1.precision(1);

  double p;

  fesetround(FE_TONEAREST);
  p = 4.5;
  s1 << p << ends;
  cout << "s1 = " << s1.str() << endl;

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22542

Reply via email to