From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/655 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: correctly rounded sqrt Date: Thu, 15 Mar 2012 09:02:44 +0100 Message-ID: <20120315080244.GL5728@port70.net> References: <20120314165604.GF5728@port70.net> <20120314190123.GH5728@port70.net> <20120315014647.GI5728@port70.net> <20120315032304.GJ5728@port70.net> <20120315050748.GC184@brightrain.aerifal.cx> <20120315053011.GK5728@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1331798581 4159 80.91.229.3 (15 Mar 2012 08:03:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 15 Mar 2012 08:03:01 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-656-gllmg-musl=m.gmane.org@lists.openwall.com Thu Mar 15 09:03:00 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1S85eF-0003Fr-Gm for gllmg-musl@plane.gmane.org; Thu, 15 Mar 2012 09:02:59 +0100 Original-Received: (qmail 18306 invoked by uid 550); 15 Mar 2012 08:02:57 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 18281 invoked from network); 15 Mar 2012 08:02:56 -0000 Content-Disposition: inline In-Reply-To: <20120315053011.GK5728@port70.net> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:655 Archived-At: * Szabolcs Nagy [2012-03-15 06:30:11 +0100]: > * Rich Felker [2012-03-15 01:07:48 -0400]: > > .global sqrt > > .type sqrt,@function > > sqrt: fldl 4(%esp) > > fsqrt > > fstsw %ax > > sub $12,%esp > > fld %st(0) > > fstpt (%esp) > > mov (%esp),%ecx > > and $0x7ff,%ecx > > cmp $0x400,%ecx > > jnz 1f > > and $0x200,%eax > > sub $0x100,%eax > > sub %eax,(%esp) > here you modify the return value even if it was nan > eg c99 F.9 recommends no nan modifications > if ((y & 0x7fff<<64) == 0x7fff<<64) ... > posix requires this as well http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_20 if (signexp >= 0x7fff) is probably a better check