Mail Archives: djgpp/1998/10/28/20:50:17
From: | moshier AT mediaone DOT net ()
|
Subject: | strtod bug in 202 beta
|
Newsgroups: | comp.os.msdos.djgpp
|
X-Newsreader: | TIN [version 1.2 PL2]
|
Lines: | 50
|
Message-ID: | <nMPZ1.49$2U3.521928@lwnws01.ne.mediaone.net>
|
Date: | Thu, 29 Oct 1998 01:44:51 GMT
|
NNTP-Posting-Host: | 24.128.118.69
|
X-Trace: | lwnws01.ne.mediaone.net 909625491 24.128.118.69 (Wed, 28 Oct 1998 20:44:51 EDT)
|
NNTP-Posting-Date: | Wed, 28 Oct 1998 20:44:51 EDT
|
Organization: | Northeast Region--MediaOne
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Using the new beta djdev202.zip the following program prints, in error,
scanf("1.1125369292536017e-308") = 0.0000000000000000e+00
This is a regression from previous releases of djpp libc.a.
-------------------------------------
char *s = "1.1125369292536017e-308";
int
main()
{
double x;
sscanf (s, "%lf", &x);
printf("scanf(\"1.1125369292536017e-308\") = %.16e\n", x);
exit(0);
}
-------------------------------------
The problem is that the result is compared with DBL_MIN, the
smallest normalized double. Thus all denormal values get flushed to zero.
The patch below seems to fix the problem.
For additional scanf exercises, please get
http://www.netlib.org/cephes/ieetst.shar
*** tmp\strtod.c Sat Jul 25 18:51:38 1998
--- strtod.c Wed Oct 28 20:24:30 1998
***************
*** 96,102 ****
for (i = 1; i <= e; i++)
{
r *= 0.1L;
! if (r < DBL_MIN) /* detect underflow */
{
errno = ERANGE;
r = 0.0;
--- 96,104 ----
for (i = 1; i <= e; i++)
{
r *= 0.1L;
! /* Detect underflow below 2^-1075, which is half
! the smallest representable double. */
! if (r < 2.47032822920623272088e-324L)
{
errno = ERANGE;
r = 0.0;
- Raw text -