This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Serious bug
- To: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Subject: Re: Serious bug
- From: Ryszard Kabatek <rysio at rumcajs dot chemie dot uni-halle dot de>
- Date: Thu, 24 Sep 1998 18:04:06 +0200 (CEST)
- cc: kabatek at chemie dot uni-halle dot de, egcs-bugs at cygnus dot com, egcs at cygnus dot com
- Reply-To: kabatek at chemie dot uni-halle dot de
On 24 Sep 1998, Alexandre Oliva wrote:
>
> Which doesn't mean egcs is wrong. It's just different, it's a
> rounding problem, with undefined results.
>
> Alexandre Oliva
It is really a problem.
It does disqualify `float' and `double'
for a lot of applications on Intel.
The sample below would produce wrong results on Intel,
but right on other platforms:
class X {
public:
X(double x) : fx(x) {}
double begin() const {return fx - 0.01;}
double end() const {return fx + 0.01;}
double value(double t)
{
if (t < begin() || t > end()) return 0.0;
return 1000.0*(end() - t)/(end() - begin());
}
private:
double fx;
};
# include <iostream.h>
int main()
{
X x(100.5);
cout << x.value(x.begin()) << '\n'; // --> 0.0 instead of 1000.0
}
Ryszard Kabatek
--
Martin-Luther University Halle-Wittenberg
Department of Physical Chemistry
Geusaer Str. 88, 06217 Merseburg, Germany
Tel. +49 3461 46 2487 Fax. +49 3461 46 2129