unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: Mark H Weaver <mhw@netris.org>
Cc: guile-devel@gnu.org
Subject: Re: [PATCH] round-ash, a rounding arithmetic shift operator
Date: Tue, 22 Feb 2011 20:16:42 +0100	[thread overview]
Message-ID: <m3mxlnx4kl.fsf@unquote.localdomain> (raw)
In-Reply-To: <8739ngx8d5.fsf@netris.org> (Mark H. Weaver's message of "Tue, 22 Feb 2011 12:54:46 -0500")

On Tue 22 Feb 2011 18:54, Mark H Weaver <mhw@netris.org> writes:

> Andy Wingo <wingo@pobox.com> writes:
>
>> On Tue 15 Feb 2011 10:49, Mark H Weaver <mhw@netris.org> writes:
>>> The first patch is trivial, but there for the sake of correctness.
>>
>> Please apply, thanks.
>
> Ludo applied this before the 2.0.0 release.

Ah, cool.

>   (define (round-ash n count)
>     (let ((r (ash n count)))
>       (if (and (negative? count)
>                (bit-set? (- -1 count) n)
>                (or (odd? r) (< (first-set-bit n) (- -1 count))))
>           (1+ r)
>           r)))

Thanks for all the explanation.

You might get good results with (logand n (ash 1 X)), given that both
logand and ash have opcodes.  Dunno.

> Having said all this, let's hold off on this patch for now.  I'm
> modifying my bigfloat module to do strictly correct rounding, and that
> may require something slightly more powerful than ash and round-ash.  In
> particular, I it may be necessary to have variants that return the
> remainder as well as the quotient, or maybe just some partial
> information about the remainder.

OK, will hold off then.  Happy hacking!

Andy
-- 
http://wingolog.org/



      reply	other threads:[~2011-02-22 19:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-15  9:49 [PATCH] round-ash, a rounding arithmetic shift operator Mark H Weaver
2011-02-20 22:06 ` Andy Wingo
2011-02-22 17:54   ` Mark H Weaver
2011-02-22 19:16     ` Andy Wingo [this message]

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

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3mxlnx4kl.fsf@unquote.localdomain \
    --to=wingo@pobox.com \
    --cc=guile-devel@gnu.org \
    --cc=mhw@netris.org \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).