https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81122

--- Comment #21 from Paul A. Bristow <pbristow at hetp dot u-net.com> ---
I also note that 

 https://en.cppreference.com/w/cpp/io/manip/fixed
    Notes
    Hexadecimal floating-point formatting ignores the stream precision
specification,
    as required by the specification of std::num_put::do_put.
  https://en.cppreference.com/w/cpp/locale/num_put/put
    Additionally, if floatfield != (ios_base::fixed | ios_base::scientific),
    then (since C++11) precision modifier is added, set to str.precision()

"When formatting a floating point value as hexfloat (i.e., when floatfield ==
(std::ios_base::fixed | std::ios_base::scientific)), the stream's precision is
not used; instead, the number is always printed with enough precision to
exactly represent the value."     (since C++11)

but this is not what MSVC currently 16.7.0.Preview 3 is implementing as noted

https://developercommunity.visualstudio.com/content/problem/520472/hexfloat-stream-output-does-not-ignore-precision-a.html

*It would be extremely unfortunate if various compilers implemented this
differently.*

I see no case for precision to change the output from std::hexfloat because it
specifies a *decimal* precision, not a hexadecimal one.  std::hexfloat output
should always be enough precision to *exactly represent the value*, however
large.

It would be nice if std::showpoint could also respect output of trailing zeros,
so that the default std::showpoint  output displays neat columns, and that
std::noshowpoint made output with minimum size (for example, minimizing
serialized data).

(In passing, I note that std::scientific always includes (often many) trailing
zeros, ignoring showpoint.  Changing this would be logical but a breaking
change.)

Reply via email to