Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Stefan Illy <stefan.illy@itp.fzk.de>
Subject: Severe errors with fscanf/sscanf (RH 4.2/5.0)
Date: Tue, 10 Feb 1998 09:38:55 +0100	[thread overview]
Message-ID: <a4e1a0be1f2c54bc02d415a85cdcf1ab.axp-list@archive.invalid> (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

-- 
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

             reply	other threads:[~1998-02-10  8:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-02-10  8:38 Stefan Illy [this message]
  -- strict thread matches above, loose matches on Subject: below --
1998-02-10 13:31 Severe errors with fscanf/sscanf (RH 4.2/5.0) Uncle George
1998-02-10 19:22 Richard Henderson
1998-02-11 17:46 Uncle George
     [not found] <34E1E403.8E292D6E@voicenet.com>
1998-02-11 19:26 ` Richard Henderson
1998-02-11 23:33 Uncle George
     [not found] <34E23533.2929FAC3@voicenet.com>
1998-02-11 23:52 ` Richard Henderson
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