This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
Re: `>>' can't read what `<<' produced: NaNs and Inf
- To: Joao Cardoso <jcardoso@inescn.pt>
- Subject: Re: `>>' can't read what `<<' produced: NaNs and Inf
- From: Benjamin Kosnik <bkoz@cygnus.com>
- Date: Tue, 30 Mar 1999 08:38:34 -0800 (PST)
- cc: libstdc++@sourceware.cygnus.com
> `<<' 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