From: Pip Cet <pipcet@gmail.com>
To: andrewjmoreton@gmail.com, eggert@cs.ucla.edu
Cc: 32463@debbugs.gnu.org
Subject: bug#32463: 27.0.50; (logior -1) => 4611686018427387903
Date: Fri, 17 Aug 2018 11:53:45 +0000 [thread overview]
Message-ID: <CAOqdjBdv+qk5v0GdtrV6X=zRE6XLfbp_OACfu7KZ6w6YR2ULVQ@mail.gmail.com> (raw)
In-Reply-To: <CAOqdjBfijfQRuO7wwsKqL0zEmXGv0Uqj7m5jFJObebdqd=5NZQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 293 bytes --]
On Fri, Aug 17, 2018 at 11:36 AM Pip Cet <pipcet@gmail.com> wrote:
> and got this output:
I forgot to mention this is on an x86-64 machine with a Linux kernel
and Debian GNU/Linux, and external libgmp.
I'm attaching the patch that I think should still be applied, which
includes some tests.
[-- Attachment #2: Minor-bignum-tweaks-002.patch --]
[-- Type: text/x-patch, Size: 3536 bytes --]
diff --git a/src/data.c b/src/data.c
index 5a355d9787c..077cc8283eb 100644
--- a/src/data.c
+++ b/src/data.c
@@ -3382,8 +3382,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);
@@ -3400,14 +3398,7 @@ ash_lsh_impl (Lisp_Object value, Lisp_Object count, bool lsh)
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));
val = make_number (result);
diff --git a/src/fns.c b/src/fns.c
index f6e68036413..5f4b455b503 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -56,15 +56,15 @@ DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0,
}
DEFUN ("random", Frandom, Srandom, 0, 1, 0,
- doc: /* Return a pseudo-random number.
-All integers representable in Lisp, i.e. between `most-negative-fixnum'
+ doc: /* Return a pseudo-random fixnum.
+All integers representable as fixnums, i.e. between `most-negative-fixnum'
and `most-positive-fixnum', inclusive, are equally likely.
-With positive integer LIMIT, return random number in interval [0,LIMIT).
-With argument t, set the random number seed from the system's entropy
-pool if available, otherwise from less-random volatile data such as the time.
-With a string argument, set the seed based on the string's contents.
-Other values of LIMIT are ignored.
+With positive fixnum integer LIMIT, return random number in interval
+[0,LIMIT). With argument t, set the random number seed from the
+system's entropy pool if available, otherwise from less-random
+volatile data such as the time. With a string argument, set the seed
+based on the string's contents. Other values of LIMIT are ignored.
See Info node `(elisp)Random Numbers' for more details. */)
(Lisp_Object limit)
diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index a4c6b0e4915..6a2578e19a0 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -614,6 +614,11 @@ binding-test-some-local
(let ((n (1+ most-positive-fixnum)))
(should (= (logxor -1 n) (lognot n)))))
+(ert-deftest data-tests-logand ()
+ (should (= -1 (logand) (logand -1) (logand -1 -1)))
+ (let ((n (1+ most-positive-fixnum)))
+ (should (= (logand -1 n) n))))
+
(ert-deftest data-tests-minmax ()
(let ((a (- most-negative-fixnum 1))
(b (+ most-positive-fixnum 1))
@@ -642,6 +647,14 @@ data-tests-check-sign
(should (= (ash most-negative-fixnum 1)
(* most-negative-fixnum 2)))
(should (= (lsh most-negative-fixnum 1)
- (* most-negative-fixnum 2))))
+ (* most-negative-fixnum 2)))
+ (should (= (ash (* 2 most-negative-fixnum) -1)
+ most-negative-fixnum))
+ (should (= (lsh (* 2 most-negative-fixnum) -1)
+ most-negative-fixnum))
+ (should (= (lsh (- (lsh most-negative-fixnum 1) 1) -1)
+ (- most-negative-fixnum 1)))
+ (should (= (ash (- (lsh most-negative-fixnum 1) 1) -1)
+ (- most-negative-fixnum 1))))
;;; data-tests.el ends here
next prev parent reply other threads:[~2018-08-17 11:53 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-17 3:29 bug#32463: 27.0.50; (logior -1) => 4611686018427387903 Katsumi Yamaoka
2018-08-17 5:59 ` Pip Cet
2018-08-17 7:40 ` Katsumi Yamaoka
2018-08-17 9:27 ` Andy Moreton
2018-08-17 11:36 ` Pip Cet
2018-08-17 11:53 ` Pip Cet [this message]
2018-08-17 13:27 ` Andy Moreton
2018-08-18 22:43 ` Paul Eggert
2018-08-17 13:24 ` Andy Moreton
2018-08-18 18:48 ` Paul Eggert
2018-08-18 18:59 ` Eli Zaretskii
2018-08-18 19:58 ` Pip Cet
2018-08-18 22:27 ` Paul Eggert
2018-08-19 15:03 ` Eli Zaretskii
2018-08-18 19:59 ` Paul Eggert
2018-08-18 19:45 ` Andy Moreton
2018-08-19 10:43 ` Live System User
2018-08-20 3:02 ` Richard Stallman
2018-08-20 3:47 ` Paul Eggert
2018-08-21 3:37 ` Richard Stallman
2018-08-18 22:56 ` Paul Eggert
2018-08-18 23:17 ` Paul Eggert
2018-08-19 10:34 ` Andy Moreton
2018-08-19 10:48 ` Pip Cet
2018-08-19 10:59 ` Paul Eggert
2018-08-19 11:32 ` Pip Cet
2018-08-21 9:40 ` Paul Eggert
2018-08-21 10:50 ` Andy Moreton
2018-08-21 14:36 ` Eli Zaretskii
2018-08-21 14:52 ` Andy Moreton
2018-08-21 17:24 ` Paul Eggert
2018-08-19 10:52 ` Paul Eggert
2018-08-22 2:29 ` Paul Eggert
2018-08-22 16:56 ` Tom Tromey
2018-08-22 17:52 ` Paul Eggert
2018-08-22 18:25 ` Eli Zaretskii
2018-08-23 0:28 ` Paul Eggert
2018-08-23 2:39 ` Eli Zaretskii
2018-08-19 18:00 ` Andy Moreton
2018-08-22 2:34 ` Paul Eggert
2018-08-22 23:27 ` Andy Moreton
2018-08-23 14:05 ` Eli Zaretskii
2018-08-22 2:56 ` Paul Eggert
2018-08-22 8:20 ` Andy Moreton
2018-08-22 8:39 ` Andy Moreton
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/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAOqdjBdv+qk5v0GdtrV6X=zRE6XLfbp_OACfu7KZ6w6YR2ULVQ@mail.gmail.com' \
--to=pipcet@gmail.com \
--cc=32463@debbugs.gnu.org \
--cc=andrewjmoreton@gmail.com \
--cc=eggert@cs.ucla.edu \
/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.savannah.gnu.org/cgit/emacs.git
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).