From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: X-Archive-Original-Message-ID: <199802050221.SAA02591@icarus.icarus.com> Date: Tue, 10 Feb 1998 09:38:55 +0100 From: Stefan Illy Subject: Severe errors with fscanf/sscanf (RH 4.2/5.0) 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 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 -- To unsubscribe: send e-mail to axp-list-request@redhat.com with 'unsubscribe' as the subject. Do not send it to axp-list@redhat.com