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: Ulrich Drepper <drepper@cygnus.com>
- Subject: Re: `>>' can't read what `<<' produced: NaNs and Inf
- From: Joao Cardoso <jcardoso@inescn.pt>
- Date: Tue, 06 Apr 1999 16:51:44 +0100
- CC: nicolai.josuttis@dvg.de, nicolai.josuttis@braunschweig.netsurf.de, Benjamin Kosnik <bkoz@cygnus.com>, libstdc++@sourceware.cygnus.com
- Organization: INESC
- References: <Pine.LNX.3.96.990330134118.32501A-100000@happy.cygnus.com> <flg16m4iiv.fsf@poivre.cmla.ens-cachan.fr> <r2u2v2trwx.fsf@happy.cygnus.com>
Ulrich Drepper wrote:
>
> Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr> writes:
...
> > Typically, this will print "Infinity" or "Inf".
> > What happens when a user tries to read back the output? Should we
> > extend the langage so that extracting "Infinity" (or "Inf") be treated
> > as a lexeme that happens to represent numeric_limits<double>::infinity()?
>
> Yes, definitely. This is what the strtod() function in glibc does.
>
> It also has to handle NaNs which can be written as
>
> NAN
> NAN(0x234)
>
Hi, I have a patch available, but I need some advise here:
1-Should NaNs and Infs be generated by the compiler, generating a
warning at library compile time (double f=1./0.;), or should they be
generated ( *f = 0x...)?
In the former case, the compiler warning can be disturbing for the user,
but it generate the numbers in an architecture independent way (VAX,
ix86, m68k, ...), while in the second case I must have the
representation of NaNs and Infs in those architectures -- unless they
are all IEEE/ISO/XXXsomething conforming.
If the correct approach is the last one, could someone check the
correctness of the following?
NaN = 0xfff8000000000000
+Inf = 0x7ff0000000000000
-Inf = 0xfff0000000000000
2-If I remember correcty, NaNs can have several internal
representations. I think that any one of them will be just as good as
the others, as "NaN OP number" is always a NaN. Is this correct?
3- My parsing recognizes:
[+-]inf[inity]
[+-]nan
with any mixing of upper or lower case.
The above construct, nan(0x234) is not recognized. Is it really needed?
Thanks for any clues,
Joao
> or any case variations (the latter version determines the mantissa bits).
>
> --
> ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace
> Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
> Cygnus Solutions `--' drepper at cygnus.com `------------------------
--
Joao Cardoso | e-mail: jcardoso@inescn.pt
INESC, R. Jose Falcao 110 | tel: + 351 2 2094322
4050 Porto, Portugal | fax: + 351 2 2008487