[Bug libstdc++/81122] New: parsing f stopped after '0' when reading std::hexfloat >> f;

2017-06-18 Thread koh...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81122

Bug ID: 81122
   Summary: parsing f stopped after '0' when reading std::hexfloat
>> f;
   Product: gcc
   Version: 6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: koh...@t-online.de
  Target Milestone: ---

Created attachment 41578
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41578=edit
commented example showing the effect

Any reading of hexfloat values is stopping after '0',
e.g. 
  std::istringstream("0x1P-1022") >> std::hexfloat >> f;
yields f = 0, next char to read is 'x'.

I'm not knowing the standard reaction, but found an example source giving the
expected result.
My source taken in parts from this source:
http://naipc.uchicago.edu/2014/ref/cppreference/en/cpp/io/manip/fixed.html

[Bug libstdc++/81122] [DR 2381] parsing f stopped after '0' when reading std::hexfloat >> f;

2018-01-26 Thread koh...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81122

--- Comment #8 from Heinz Kohl <koh...@t-online.de> ---
o.k., it looks like a flawy definition.

First of all, it would be nice, if you would refer my error message to the
right instance.

It's unclear, what's to do in the meantime.
An idea might give, what's a simple C++-user like me would expect in this
case(s).
That may be one of the following:
1) no change of behavior 
2) read is symmetric to write
Both together isn't possible.

Standards for programming language are imperfect. That's a very known situation
in the history of programming languages at least since Algol60 (when I was an
implementor).
There's no really conforming implementation possible, when the standard is
faulty.
The difference between a good and a bad implementation is laying not at least
in the way to cope with this problem. Usability, not principled implementation
is the criterion for a good implementation.

The classical considerations are "What seems to be the best work around for
users? What's the best work around for me as implementor? What are other
implementers doing? Is it better to use implement a mostly restricted manner,
or in a mostly wide, or let the user select dependend on an option?".

Every of these cases may violate expectations and should be documented
therefore.
For all these cases it seems to be necessary to document the decision, at least
in the user's guide.

For many applications it's expected to read exactly the same value as written.
Without the possibility to do it with hexfloat, there's no safe base to do
that.

The only possible way to document floating point values in an exact manner
indepently to the internal representation is to use this format, not only, but
especially when using multi precision floating point numbers.
When there's no possibility to read these values back, this is senseless -
more, it looks like a crazy joke.

(my workaround: add 64 bits of precision, write decimal, analyze input for
values like inf, -inf, nan, else read decimal. It's still inexactly beside a
lot more programming and spending much more space and time at runtime).

[Bug libstdc++/81122] [DR 2381] parsing f stopped after '0' when reading std::hexfloat >> f;

2018-01-27 Thread koh...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81122

--- Comment #13 from Heinz Kohl <koh...@t-online.de> ---
O.k., but following your arguments I'd expect 0xb as result for my second
example 0xb.3590da0e2a06736p-3 (attachment 41578), but it's giving 0, also
stopping at 'x' and not at '.', just as in the first case.

It might be just another case of the same problem, but I'm not sure.

An actual test run:

./a.out
Parsing 0x1P-1022 as hex gives 0
Parsing '0xb.3590da0e2a06736p-3 xyz' as hex gives 0 xb.

(The source code for the second example is:
  std::istringstream("0xb.3590da0e2a06736p-3 xyz") >> std::hexfloat >> g >> a
>> b >> c ;
  std::cout << "Parsing '0xb.3590da0e2a06736p-3 xyz' as hex gives " << g << ' '
<< a << b << c << std::endl; 
)