www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2009/09/14/15:23:22

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
X-Authenticated: #27081556
X-Provags-ID: V01U2FsdGVkX19zv1EUeq5zaxLLHuuNiLXbiRuDXV9GM77sBzPUZF
lJ/e4fRrkbchGP
From: Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
To: djgpp-workers AT delorie DOT com
Subject: atan2 bug
Date: Mon, 14 Sep 2009 21:22:34 +0200
User-Agent: KMail/1.9.10
MIME-Version: 1.0
Message-Id: <200909142122.34236.juan.guerrero@gmx.de>
X-Y-GMX-Trusted: 0
X-FuHaFi: 0.54
Reply-To: djgpp-workers AT delorie DOT com

The code of atan2 contains a bug.  As can be seen it is tried to check if
the double x variable is inf by checking if the mantissa is identical zero.
On the stack the 64 bit x variable occupies esp + 16 and esp + 12.  It makes
no sense to check the mantissa high part at esp + 16 that corresponds to
the x variable and the manstissa low part at esp + 4 that corresponds to
the y variable.

|s|exp|man h|  <-- esp + 16 \
|   man l   |  <-- esp + 12 / (64 bit ieee) double x
|s|exp|man h|  <-- esp + 8  \
|   man l   |  <-- esp + 4  / (64 bit ieee) double y

It seems to be a "copy and paste" error.


Regards,
Juan M. Guerrero




2009-09-14  Juan Manuel Guerrero  <juan DOT guerrero AT gmx DOT de>
	Diffs against djgpp CVS head of 2009-08-16.


	* src/libc/ansi/math/atan2.S: Check mantissa of y and not mantissa of x.





diff -aprNU5 djgpp.orig/src/libc/ansi/math/atan2.S djgpp/src/libc/ansi/math/atan2.S
--- djgpp.orig/src/libc/ansi/math/atan2.S	1999-08-04 19:58:20 +0000
+++ djgpp/src/libc/ansi/math/atan2.S	2009-09-14 20:55:50 +0000
@@ -45,12 +45,12 @@ aby:
 	jmp	badarg
 
 abx:
 	movl	16(%esp), %eax		/* inf or NaN */
 	testl	$0x000FFFFF, %eax
-	jnz	badarg
-	movl	4(%esp), %eax
+	jne	badarg			/* x = NaN */
+	movl	12(%esp), %eax
 	testl	%eax, %eax
 	jnz	badarg
 
 	movl	8(%esp), %eax
 	andl	$0x7FF00000,%eax

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019