From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Andy Moreton Newsgroups: gmane.emacs.bugs Subject: bug#32463: 27.0.50; (logior -1) => 4611686018427387903 Date: Fri, 17 Aug 2018 10:27:25 +0100 Message-ID: <86mutll4w2.fsf@gmail.com> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1534498329 822 195.159.176.226 (17 Aug 2018 09:32:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 17 Aug 2018 09:32:09 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (windows-nt) To: 32463@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Aug 17 11:32:05 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fqb6z-00005j-H0 for geb-bug-gnu-emacs@m.gmane.org; Fri, 17 Aug 2018 11:32:05 +0200 Original-Received: from localhost ([::1]:60837 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqb95-0006J7-Px for geb-bug-gnu-emacs@m.gmane.org; Fri, 17 Aug 2018 05:34:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56786) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqb8x-0006I1-By for bug-gnu-emacs@gnu.org; Fri, 17 Aug 2018 05:34:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqb8s-0000u2-A3 for bug-gnu-emacs@gnu.org; Fri, 17 Aug 2018 05:34:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48242) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fqb8s-0000tt-6N for bug-gnu-emacs@gnu.org; Fri, 17 Aug 2018 05:34:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fqb8s-0008KU-3Q for bug-gnu-emacs@gnu.org; Fri, 17 Aug 2018 05:34:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Andy Moreton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 17 Aug 2018 09:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32463 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.153449840831926 (code B ref -1); Fri, 17 Aug 2018 09:34:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 17 Aug 2018 09:33:28 +0000 Original-Received: from localhost ([127.0.0.1]:53259 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fqb8J-0008Ir-Sy for submit@debbugs.gnu.org; Fri, 17 Aug 2018 05:33:28 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:35129) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fqb8I-0008IT-LW for submit@debbugs.gnu.org; Fri, 17 Aug 2018 05:33:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqb8B-00009p-E8 for submit@debbugs.gnu.org; Fri, 17 Aug 2018 05:33:21 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:57326) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fqb88-00007Q-Q7 for submit@debbugs.gnu.org; Fri, 17 Aug 2018 05:33:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqb83-0005f0-Gg for bug-gnu-emacs@gnu.org; Fri, 17 Aug 2018 05:33:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqb2f-0004lc-W9 for bug-gnu-emacs@gnu.org; Fri, 17 Aug 2018 05:27:41 -0400 Original-Received: from [195.159.176.226] (port=35542 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fqb2f-0004kq-PJ for bug-gnu-emacs@gnu.org; Fri, 17 Aug 2018 05:27:37 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fqb0W-0000Qt-7d for bug-gnu-emacs@gnu.org; Fri, 17 Aug 2018 11:25:24 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 56 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:8Hu5MK0hzWw8yYWdkKxjFqZlPZc= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:149551 Archived-At: On Fri 17 Aug 2018, Pip Cet wrote: > Can you try the attached patch? It fixes a few things that I reported > to Tom yesterday: > > --- > > > None of these are necessarily bugs, but: > > * I find the behavior of `lsh', `logand', `logior', and `logxor', when > given negative arguments, surprising. I think it would make most sense > to treat negative numbers as the infinite bitstream consisting of all > ones to the left of the specified value: > > (logand -1 -1) would be interpreted as ...1111111 & ...1111111 = > ...1111111, so it would be -1 (rather than 2 * most-positive-fixnum + > 1). > (lsh (- (lsh -1 64) 1) -1) would be ...1110111...1111 shifted to the > right by one digit, an odd number, rather than the even number > currently produced. (I believe lsh and ash should behave identically.) > @@ -3383,8 +3383,6 @@ ash_lsh_impl (Lisp_Object value, Lisp_Object count, bool lsh) > mpz_init (result); > if (XFIXNUM (count) >= 0) > mpz_mul_2exp (result, XBIGNUM (value)->value, XFIXNUM (count)); > - else if (lsh) > - mpz_tdiv_q_2exp (result, XBIGNUM (value)->value, - XFIXNUM (count)); > else > mpz_fdiv_q_2exp (result, XBIGNUM (value)->value, - XFIXNUM (count)); > val = make_number (result); > @@ -3401,14 +3399,7 @@ ash_lsh_impl (Lisp_Object value, Lisp_Object count, bool lsh) Please add more test cases to test/src/data-tests.el to ensure that the logical operations have the expected behaviour for positive and negative arguments, and for both bignum and fixnum arguments. The tdiv/fdiv were added to give expected results. Pay particular attention to values around most-positive-fixnum and most-negative-fixnum. > if (XFIXNUM (count) >= 0) > mpz_mul_2exp (result, result, XFIXNUM (count)); > - else if (lsh) > - { > - if (mpz_sgn (result) > 0) > - mpz_fdiv_q_2exp (result, result, - XFIXNUM (count)); > - else > - mpz_fdiv_q_2exp (result, result, - XFIXNUM (count)); > - } > - else /* ash */ > + else > mpz_fdiv_q_2exp (result, result, - XFIXNUM (count)); This part is an obvious simplification and is fine (I should have spotted it before sending my patch that Tom committed). AndyM