[comp.sys.atari.st] bug in GCC floating point lib

piet@cs.ruu.nl (Piet van Oostrum) (10/31/89)

I discovered a bug in the double precision floating point lib by Scott
McCauley/John Dunning (dflonum.c). The routine to convert doubles to
floating had a long where an unsigned long was required, thus causing a
right shift to do a sign extend. This gives a few bit errors in some
conversions. There was also a superfluous satement. Here is a patch:

*** dflonum.c.~1~	Thu Jul 13 12:27:25 1989
--- dflonum.c	Fri Oct 27 09:52:42 1989
***************
*** 636,642 ****
  double f;
  {
  	struct bitdouble *bdp;
! 	int si, ex, mant1, mant2;
  	bdp = &f;
  	si = bdp->sign;
  	ex = bdp->exp;
--- 636,643 ----
  double f;
  {
  	struct bitdouble *bdp;
! 	int si, ex;
! 	unsigned long mant1, mant2;
  	bdp = &f;
  	si = bdp->sign;
  	ex = bdp->exp;
***************
*** 644,650 ****
  	mant2 = bdp->mant2;
  
  	/* zero value */
! 	if (ex == 0) return(0L);
  	/* less than 1 */
  	if (ex < 0x3ff) return(0L);
  	/* less than 0 */
--- 645,651 ----
  	mant2 = bdp->mant2;
  
  	/* zero value */
! /*	if (ex == 0) return(0L); */ /* this is covered in next line */
  	/* less than 1 */
  	if (ex < 0x3ff) return(0L);
  	/* less than 0 */
-- 
Piet van Oostrum, Dept of Computer Science, University of Utrecht
Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht,  The Netherlands.
Telephone: +31-30-531806      Internet: piet@cs.ruu.nl
Telefax:   +31-30-513791      Uucp: uunet!mcsun!hp4nl!ruuinf!piet