Mail Archives: cygwin/2007/05/03/15:02:24
On 5/2/07, Cary R. wrote:
> > Other potentially controversial special cases (may or may not be
> > handled correctly by newlib -- I didn't check) are:
> > atan2(+-0,-0)=+-pi
> > atan2(+-0,+0)=+-0
>
> newlib and my version of glibc return +0 for all these cases.
Hmm.... *my* version of glibc gets all 4 cases right:
lsb32 AT cmt:~> cat atan2.c
#include <stdio.h>
#include <math.h>
int main()
{
double zero, mzero;
zero = 0.0;
mzero= -1.0*0;
printf("Using +0=%f -0=%f\n",zero,mzero);
printf("atan2(+0,+0)=%f\n",atan2(zero,zero));
printf("atan2(-0,+0)=%f\n",atan2(mzero,zero));
printf("atan2(+0,-0)=%f\n",atan2(zero,mzero));
printf("atan2(-0,-0)=%f\n",atan2(mzero,mzero));
return 0;
}
lsb32 AT cmt:~> gcc -Wall -fno-builtin atan2.c -lm &&./a.out
Using +0=0.000000 -0=-0.000000
atan2(+0,+0)=0.000000
atan2(-0,+0)=-0.000000
atan2(+0,-0)=3.141593
atan2(-0,-0)=-3.141593
lsb32 AT cmt:~> /lib/libc.so.6
GNU C Library development release version 2.4 (20060526), by Roland
McGrath et al.
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Configured for i686-suse-linux.
Compiled by GNU CC version 4.1.0 (SUSE Linux).
Compiled on a Linux 2.6.16 system on 2006-05-26.
Available extensions:
crypt add-on version 2.1 by Michael Glad and others
GNU Libidn by Simon Josefsson
GNU libio by Per Bothner
NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
NoVersion patch for broken glibc 2.0 binaries
Native POSIX Threads Library by Ulrich Drepper et al
BIND-8.2.3-T5B
Thread-local storage support included.
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
lsb32 AT cmt:~> uname -a
Linux cmt 2.6.16.21-0.25-smp #1 SMP Tue Sep 19 07:26:15 UTC 2006 i686
i686 i386 GNU/Linux
Newlib gets it wrong and puts out +0 in all cases, as you said, but
interestingly gcc -mno-cygwin gets all cases correct (although you
have to work a bit harder to prove that because mingw's printf()
doesn't distinguish +0 and -0 in it's output).
Lev
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -