From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12185 Path: news.gmane.org!.POSTED!not-for-mail From: John Reiser Newsgroups: gmane.linux.lib.musl.general Subject: Re: remquo - underlying logic Date: Thu, 30 Nov 2017 13:16:01 -0800 Message-ID: <23771268-ef99-871c-535e-addff914196d@bitwagon.com> References: <20171130185956.GS15263@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1512076580 27778 195.159.176.226 (30 Nov 2017 21:16:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 30 Nov 2017 21:16:20 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 To: musl@lists.openwall.com Original-X-From: musl-return-12201-gllmg-musl=m.gmane.org@lists.openwall.com Thu Nov 30 22:16:17 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1eKWBm-0006e7-O3 for gllmg-musl@m.gmane.org; Thu, 30 Nov 2017 22:16:10 +0100 Original-Received: (qmail 30141 invoked by uid 550); 30 Nov 2017 21:16:16 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 30120 invoked from network); 30 Nov 2017 21:16:15 -0000 In-Reply-To: Content-Language: en-US Xref: news.gmane.org gmane.linux.lib.musl.general:12185 Archived-At: > I was asking the question in case anybody had done it before and found it useless, > could think of major pitfalls, or had any pearls of wisdom before we started. The range of a floating-point exponent will limit the applicability. Packing and unpacking floating-point format (logb, scalb, etc.) are non-trivial costs, as are mucking around with NaN, +inf, -inf, denormals, etc. The "big-O" efficiency is the same: find the difference in exponents, scale both operands to have the same exponent, perform "ordinary long division" with the number of steps equal to the difference in exponents; take care to preserve enough precision. Floating-point division of the scaled operands (perhaps using a narrower precision) can be a contender, especially because mis-predicted branches in long division are VERY expensive (typically: 70% of CPU pipeline depth [==> a dozen or more cycles].) Newton-Raphson iteration can be a contender for some range of difference in exponents. --