Gonzalo Tornaria wrote: > On Wed, Dec 30, 2009 at 10:38 PM, Dr. David Kirkby > <david.kir...@onetel.net> wrote: >> Em, This is very odd. exp(1) gives a different result on SPARC if you build >> with gcc or Sun Studio. GCC is correct, and Sun Studio is wrong. Yet Sage on >> 't2' was build with gcc, not Sun Studio. > > gcc is actually inlining exp(1.0) to its correct value. The exp() from > the sun library is incorrect. Try this program instead: > > #include <math.h> > #include <stdio.h> > #include <stdlib.h> > > int main(int argc, char **argv) { > double x = 1.0; > if (argc>1) > x = atof(argv[1]); > printf("%.16lf\n",exp(x)); > } > > Best, Gonzalo >
Hi, Thank you. Yes, your version forces a call to the library, which does give the less accurate result (2.7182818284590455). The data below is on my own SPARC, not 't2', but results should be the same. drkir...@kestrel:~$ gcc -lm exp.c drkir...@kestrel:~$ ./a.out 2.7182818284590451 drkir...@kestrel:~$ gcc -lm exp2.c drkir...@kestrel:~$ ./a.out 2.7182818284590455 Da I believe you have got to the bottom of this now. I also noted that if I try to compile and link my version, without linking in the maths library, so it compiles and links fine. But if I try your version (which I called exp2.c), the link fails. bash-3.2$ gcc exp.c bash-3.2$ gcc exp2.c Undefined first referenced symbol in file exp /var/tmp//cc2qaGNG.o ld: fatal: symbol referencing errors. No output written to a.out collect2: ld returned 1 exit status Dave -- 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