From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/648 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: correctly rounded sqrt Date: Wed, 14 Mar 2012 17:56:05 +0100 Message-ID: <20120314165604.GF5728@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 1331744180 19466 80.91.229.3 (14 Mar 2012 16:56:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 14 Mar 2012 16:56:20 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-649-gllmg-musl=m.gmane.org@lists.openwall.com Wed Mar 14 17:56:19 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 1S7rUo-00026j-7d for gllmg-musl@plane.gmane.org; Wed, 14 Mar 2012 17:56:18 +0100 Original-Received: (qmail 1669 invoked by uid 550); 14 Mar 2012 16:56:17 -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 1657 invoked from network); 14 Mar 2012 16:56:17 -0000 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:648 Archived-At: i tried to solve the sqrt issue with a wrapper as discussed on irc, but i couldn't find a nice solution if we check |x - y*y| and try to figure out the rounding from that, then there are two approaches 1) use the veltkamp-dekker exact multiplication formulas (sq1 algorithm in my code) or 2) use simpler method for y*y and use argumentum reduction to handle large/small numbers (x*=2^2n, y*=2^-n) i tried both: 1) only works correctly for subnormals with double precision evaluation so it needs arg reduction 2) does not work in all cases (|x-y*y| and |x-y1*y1| might be the same and resolving the tie is nontrivial) so 1) with arg reduction is my current solution and i don't know if it works in all cases ..and the code might be slow