From: Stefan Illy <stefan.illy@itp.fzk.de>
Subject: Severe error with fscanf/sscanf (RH 4.2/5.0)
Date: 1998/02/10 [thread overview]
Message-ID: <ud67mnsuw0.fsf@itpgyro1.fzk.de> (raw)
I encountered a serious problem on our two Linux-based Alphas:
Both fscanf and sscanf produce errors when reading small
floating point numbers (type double, exponent approx. -70) from
files or strings. It happens only for a fraction of possible
numbers (something in the range of 0.1 to 1 %, I don't know exactly).
The following small C program should show this behaviour.
On our systems it will produce the result `1.083877e-56' which differs
from the input by 20 orders of magnitude!
------------------------------------------------------------------------
#include <stdio.h>
int
main()
{
char str[256];
double x;
sprintf(str, "5.9e-76");
sscanf(str, "%le", &x);
fprintf(stdout, "%e\n", x);
exit(0);
}
------------------------------------------------------------------------
Adding one digit to the input (e.g. `5.91e-76'), will result in
correct output.
The behavior is compiler-independent, I was able to reproduce it with
FORTRAN (both f2c/gcc-2.7.2.3 and g77/egcs-1.0.1) and
the iostream operators of C++ (both gcc-2.7.2.3 and egcs-1.0.1).
The hardware of both systems is identical (except of graphics card and
peripheral devices):
PC164 Motherboard
500 MHz 21164 Chip
256 MByte Memory
The first system is running Redhat 4.2,
Kernel updated to 2.0.32 (no additional patches),
libc package: glibc-0.961212-7.
The second system is running Redhat 5.0,
Kernel updated to 2.0.32 (with alpha-patches-2.0.32-0.1.gz)
libc package: glibc-2.0.5c-13.
I am very interested, if someone could reproduce this behavior on
PC164 and non-PC164 based systems.
Where is the origin of this bug? libc, kernel, compilers?
Best wishes, Stefan
--
Stefan Illy |
Institut fuer Technische Physik (ITP) |
Forschungszentrum Karlsruhe GmbH | e-mail: stefan.illy@itp.fzk.de
Hermann-von-Helmholtz-Platz 1 | phone: (+49) 07247/82-4165
D-76344 Eggenstein-Leopoldshafen, Germany | fax: (+49) 07247/82-2849
reply other threads:[~1998-02-10 5:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox