From: John Reiser <jreiser@bitwagon.com>
To: musl@lists.openwall.com
Subject: Re: remquo - underlying logic
Date: Thu, 30 Nov 2017 13:16:01 -0800 [thread overview]
Message-ID: <23771268-ef99-871c-535e-addff914196d@bitwagon.com> (raw)
In-Reply-To: <alpine.LRH.2.02.1712010723070.4154@key0.esi.com.au>
> 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.
--
next prev parent reply other threads:[~2017-11-30 21:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-30 18:11 Damian McGuckin
2017-11-30 18:59 ` Szabolcs Nagy
2017-11-30 20:29 ` Damian McGuckin
2017-11-30 21:16 ` John Reiser [this message]
2017-11-30 21:17 ` Szabolcs Nagy
2017-12-04 8:10 ` Damian McGuckin
2017-12-06 1:17 ` Damian McGuckin
2017-12-06 10:37 ` Szabolcs Nagy
2017-12-07 1:09 ` Damian McGuckin
2017-12-08 0:42 ` Szabolcs Nagy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=23771268-ef99-871c-535e-addff914196d@bitwagon.com \
--to=jreiser@bitwagon.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).