[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] round-ash, a rounding arithmetic shift operator

From: Andy Wingo
Subject: Re: [PATCH] round-ash, a rounding arithmetic shift operator
Date: Tue, 22 Feb 2011 20:16:42 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

On Tue 22 Feb 2011 18:54, Mark H Weaver <address@hidden> writes:

> Andy Wingo <address@hidden> writes:
>> On Tue 15 Feb 2011 10:49, Mark H Weaver <address@hidden> 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!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]