X-Spam-Check-By: sourceware.org Message-ID: Date: Thu, 3 May 2007 15:01:45 -0400 From: "Lev Bishop" To: cygwin AT cygwin DOT com Subject: Re: newlib?: pow function can produce incorrect results. In-Reply-To: <476923.14782.qm@web59106.mail.re1.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <476923 DOT 14782 DOT qm AT web59106 DOT mail DOT re1 DOT yahoo DOT com> Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 #include 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: . 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/