On 02/ 2/12 04:45 AM, Dima Pasechnik wrote:
Here is an illustration of the same phenomenon on x86_64. There, of course,
8-byte floats are double, so the code to demonstrate
the problem is as follows:
#include<stdio.h>
#include<math.h>
int main ()
{
   double x = 6.0;
   printf("sizof(double)=%d\n",sizeof(double));
   printf("lgamma (%.20f)=%.20f\n", x, lgamma(x));
   printf("tgamma (%.20f)=%.20f\n", x, tgamma(x));
   printf("exp(lgamma) (%.20f)=%.20f\n", x, exp(lgamma(x)));
   return 0;
}
On x86_64 Linux, it outputs
sizof(double)=8
lgamma (6.00000000000000000000)=4.78749174278204581157
tgamma (6.00000000000000000000)=119.99999999999997157829
exp(lgamma) (6.00000000000000000000)=119.99999999999997157829

On MacOSX, libc has an honest gamma(), which does the job properly:
sizof(double)=8
lgamma (6.00000000000000000000)=4.78749174278204492339
tgamma (6.00000000000000000000)=120.00000000000000000000
exp(lgamma) (6.00000000000000000000)=119.99999999999987210231

So eglibc does a bad job computing gamma() on double (i.e. on 8-byte
floats)...

Report upstream?

Dima



Here's two from OpenSolaris on x86 - one with gcc, the other with the Sun compiler 'cc'

drkirkby@hawk:~$ gcc test.c -lm
drkirkby@hawk:~$ ./a.out
sizof(double)=8
lgamma (6.00000000000000000000)=4.78749174278204581157
tgamma (6.00000000000000000000)=120.00000000000000000000
exp(lgamma) (6.00000000000000000000)=119.99999999999997157829


drkirkby@hawk:~$ cc test.c -lm
drkirkby@hawk:~$ ./a.out
sizof(double)=8
lgamma (6.00000000000000000000)=4.78749174278204581157
tgamma (6.00000000000000000000)=120.00000000000000000000
exp(lgamma) (6.00000000000000000000)=119.99999999999997157829

Same result on each I think (someone can check, as I really must rush and cant check every digit).

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to