From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] round-ash, a rounding arithmetic shift operator Date: Tue, 22 Feb 2011 20:16:42 +0100 Message-ID: References: <87vd0l631d.fsf@netris.org> <8739ngx8d5.fsf@netris.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1298401906 12006 80.91.229.12 (22 Feb 2011 19:11:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 22 Feb 2011 19:11:46 +0000 (UTC) Cc: guile-devel@gnu.org To: Mark H Weaver Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Feb 22 20:11:41 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Prxe6-0005Nv-VI for guile-devel@m.gmane.org; Tue, 22 Feb 2011 20:11:39 +0100 Original-Received: from localhost ([127.0.0.1]:41682 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Prxe6-0001Ay-78 for guile-devel@m.gmane.org; Tue, 22 Feb 2011 14:11:38 -0500 Original-Received: from [140.186.70.92] (port=42872 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Prxdy-00018W-Mx for guile-devel@gnu.org; Tue, 22 Feb 2011 14:11:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Prxdx-0003Y6-Dz for guile-devel@gnu.org; Tue, 22 Feb 2011 14:11:30 -0500 Original-Received: from a-pb-sasl-sd.pobox.com ([64.74.157.62]:34755 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Prxdx-0003Y1-54 for guile-devel@gnu.org; Tue, 22 Feb 2011 14:11:29 -0500 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 270863118; Tue, 22 Feb 2011 14:12:40 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=50/HYn7rOQOYjrN0PZHO1VOyKeY=; b=JKc6rb Mv9Bt0in+ouXJjLct+KYu57D5dv1t3pMtwHoMSO9A9HPNzKkARk9qJ0jsrtYaM+s /Oy3bYBt96wRCf+ktd6drUNVC6sMRYaWl2gHzHb3hC7uKTPzvcILhPy+0A/iyNov keOaQizRSb6HQbDyi3h0c5PQWBmSpQeixoVW4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=CN4uq8KsmZ0k6oAts225Y4cwuEdhFn1n YnlJ3/t/wjPmE5zZAoqK54VDGE+PdfCMekrdTWe7PliTwyw0mhScSuX0d9mpbtoH Tmx3QbJKfHhsi5CUn+01NJIrdTphb0DJw8SwXsempcMNQ/7qzN119eo8+ke6G6vo 4I3qdXQiqV8= Original-Received: from a-pb-sasl-sd.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 138D33117; Tue, 22 Feb 2011 14:12:39 -0500 (EST) Original-Received: from unquote.localdomain (unknown [90.164.198.39]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTPSA id CB47A3116; Tue, 22 Feb 2011 14:12:35 -0500 (EST) In-Reply-To: <8739ngx8d5.fsf@netris.org> (Mark H. Weaver's message of "Tue, 22 Feb 2011 12:54:46 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) X-Pobox-Relay-ID: B6F1D14E-3EB7-11E0-8F33-AF401E47CF6F-02397024!a-pb-sasl-sd.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 64.74.157.62 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:11685 Archived-At: On Tue 22 Feb 2011 18:54, Mark H Weaver writes: > Andy Wingo writes: > >> On Tue 15 Feb 2011 10:49, Mark H Weaver 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/