This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project. See the libstdc++ home page for more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: `>>' can't read what `<<' produced: NaNs and Inf


> `<<' generate special tokens when outputing float/doubles that are
> not numbers (NaN) or are infinity (Inf).
> However, `>>' can't read those tokens. Is this deliberate?

No. Note that istream::operators>>'s in particular are a moving target:
they were not working in the last snapshot, and are not yet in their final
state in CVS. 

> If I submit a patch to make libstdc++ read what it output, will it be
> accepted (in principle)? I think that no standard specify it...

If you have a patch, submit it.

Here's more info:

http://sourceware.cygnus.com/libstdc++/contribute.html

> #include <strstream.h>
> 
> main(){
>         double f=1./0., g=0./0., h, l;
>         char buf[100];
> 
>         ostrstream os(buf,100);
>         istrstream is(buf,100);
> 
>         cout << f << " " << g << '\n';
>         os << f << g << '\0';
>         
>         is >> h >> l;;
>         cout << h << " " << l << '\n';
> }
> 
> ./foo
> Infinity -NaN
> 8.59409e-313 -1.01297e-309

I'll look at this later today, after I resolve other outstanding
operator>> items. Thanks for the clear test case.

-Benjamin