This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


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

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


Hi,

[I have recently put a question on the egcs mailing list, but this is
the correct place to do it, I think.]

`<<' 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?

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...

I think that making libio/iovfscanf.c read what libio/outfloat.c and
libio/floatconv.c generate will be enought.

foo.cc:

#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
 

Comments?

Joao

PS-I am not a subscriber of this list, but I will watch it regularly in
the next days.

-- 
Joao Cardoso                |   e-mail: jcardoso@inescn.pt
INESC, R. Jose Falcao 110   |   tel:	+ 351 2 2094322
4050 Porto, Portugal        |   fax:	+ 351 2 2008487


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