Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: yxc02740@Bayou.UH.EDU
Subject: Re: GCC bug???
Date: Fri, 15 Mar 1996 16:54:16 -0600 (CST)	[thread overview]
Message-ID: <199603152254.QAA27149@Bayou.UH.EDU> (raw)
In-Reply-To: <199603152047.PAA02208@Adeno.wistar.upenn.edu>

> 
> 
> Hello Alpha users -
> 
> 	I'm not sure if this qualifies as a bug in the technical sense, but
> it seems at least to be an inconsistany between Alpha Linux/GCC and
> x86 Linux/GCC.  I ran into this problem with the math lib function pow(), but 
> it may occur elsewhere.  It occurs when incorrectly typed variables 
> (ints, or longs) are passed to the pow() function, which as I understand, 
> expects doubles.  I compiled the following code with GCC on a Linux/Pentium 
> system and it works fine:
It is not a GCC bug, but it is a library bug. It turns out that the
linux/alpha's libm.a is not only slow, but also buggy. You problem is caused
by a last digit rounding error for pow() function. I don't know if a standard
IEEE floating point library allows such error, but at least, a 487 chip
returns correct value.
The Alpha/Linux's math library has not been implemented, it is just copied
from generic RICS codes. I would like to know if sb. is working on this
problem, we difinetely need a better math library.
> 
> #include <stdlib.h>
> #include <math.h>
> 
> main()
> {
>     int i;
>     int x;
>     for (i=0;i<6;i++)
>     {
>      x=pow(2,i);
>        printf("%d   %ld\n",i,x);
>     }
> }
> Output is:
> 0   1
> 1   2
> 2   4
> 3   8
> 4  16
> 5  32
> 
> The same code compiled on Linux/Alpha gives :
> #include <stdlib.h>
> #include <math.h>
> 
> main()
> {
>     int i;
>     int x;
>     for (i=0;i<6;i++)
>     {
>      x=pow(2,i);
>        printf("%d   %ld\n",i,x);
>     }
> }
> Output :
> 0   1
> 1   2
> 2   4
> 3   7
> 4   15
> 5   32
> 
> It seems to be something strange in the conversion from one type to another.
> For example : 
>  main()
>  {
>      int i;
>      double x,y;
>      for (i=0;i<21;i++)
>      {
>         x= pow(2.0,i);
>         y = (int)x;
>         printf("%d   %g %g\n",i,x,y);
>      }
>  }
> 
> Gives Output:
> 0   1   1
> 1   2   2
> 2   4   4
> 3   8   7
> 4   16   15
> 5   32   32
> 
> There are no warnings of potential problems at compile time and because
> this problem does not occur with the x86 GCC (I haven't tried any other
> platforms).  Being a C beginner, I'm not sure what should happen, but I think
> at least a warning is warrented.
> 
> Jeff Taylor
> 

yansong chen
yxc02740@bayou.uh.edu

       reply	other threads:[~1996-03-15 22:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <199603152047.PAA02208@Adeno.wistar.upenn.edu>
1996-03-15 22:54 ` yxc02740 [this message]
1997-04-05 16:22 gcc bug? Michael Alan Dorman
  -- strict thread matches above, loose matches on Subject: below --
1996-03-15 23:52 GCC bug??? David Mosberger-Tang
1996-03-15 20:47 Jeff Taylor
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