[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Slowness in function 'open'
From: |
John W. Eaton |
Subject: |
Re: Slowness in function 'open' |
Date: |
Fri, 22 Jun 2007 23:22:55 -0400 |
On 22-Jun-2007, Jordi Gutierrez Hermoso wrote:
| > 4. handle reading Inf and NaN values even when the underlying C/C++
| > library does not
|
| Oy. That's complicated. Why do we need that? You mean we can't assume
| std::numeric_limits<double>::quiet_NaN() will yield the value we want?
| A standards-abiding C++ implementation has to report with
| std::numeric_limits<double>::has_quiet_NaN() if it has decided to not
| adhere to IEC 559. Are there still any major C++ implementations out
| there for which this matters? Surely even the Playstation 3 adheres to
| IEEE arithmetic, doesn't it? That's about the weirdest platform I can
| remember on which someone has tried to run Octave as reported on the
| help list. :-)
Maybe I wasn't clear. I don't think it has anything to do with
std::numeric_limits. We're talking about reading numbers from text
files. So if the file contains "NaN" or "Inf", we have to recognize
that. Even my trusty Debian system with the GNU C library and the
current libstdc++ does not handle this case. Given the program:
#include <iostream>
int
main (void)
{
double d = 0;
std::cin >> d;
if (std::cin)
std::cout << d << std::endl;
else
std::cerr << "oops!" << std::endl;
return 0;
}
I see:
$ echo 42 | ./a.out
42
$ echo NaN | ./a.out
oops!
$ echo Inf | ./a.out
oops!
We also need to be able to read "NA" as a missing value, and it also
helps to be able to read other variations like "inf", "INF", "nan",
and "NAN". Bonus points for reading "NaNQ", "Infinity" or whatever
might show up in text files, but I don't think that is necessary. At
least Octave won't write those strings (it always writes "NA", "NaN",
or "Inf").
jwe