From: Kevin Ryde <user42@zip.com.au>
Subject: logcount negatives
Date: Sun, 04 May 2003 09:37:58 +1000 [thread overview]
Message-ID: <87issrlhyh.fsf@zip.com.au> (raw)
[-- Attachment #1: Type: text/plain, Size: 169 bytes --]
A small fix for logcount on negatives,
* numbers.c (scm_logcount): Use mpz_com not mpz_neg for negatives.
* tests/numbers.test (logcount): Exercise some negatives.
[-- Attachment #2: numbers.c.logcount.diff --]
[-- Type: text/plain, Size: 389 bytes --]
--- numbers.c.~1.181.~ 2003-05-04 09:09:49.000000000 +1000
+++ numbers.c 2003-05-04 09:34:56.000000000 +1000
@@ -1387,7 +1387,7 @@
{
mpz_t z_n;
mpz_init (z_n);
- mpz_neg (z_n, SCM_I_BIG_MPZ (n));
+ mpz_com (z_n, SCM_I_BIG_MPZ (n));
scm_remember_upto_here_1 (n);
count = mpz_popcount (z_n);
mpz_clear (z_n);
[-- Attachment #3: numbers.test.logcount.diff --]
[-- Type: text/plain, Size: 377 bytes --]
--- numbers.test.~1.17.~ 2003-05-04 09:11:34.000000000 +1000
+++ numbers.test 2003-05-04 09:31:46.000000000 +1000
@@ -1739,3 +1739,16 @@
;;;
;;; inexact->exact
;;;
+
+;;;
+;;; logcount
+;;;
+
+(with-test-prefix "logcount"
+
+ (with-test-prefix "negatives ...11100..00"
+ (do ((n -1 (ash n 1))
+ (i 0 (1+ i)))
+ ((> i 256))
+ (pass-if n
+ (= i (logcount n))))))
[-- Attachment #4: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
next reply other threads:[~2003-05-03 23:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-03 23:37 Kevin Ryde [this message]
2003-05-04 0:15 ` logcount negatives Marius Vollmer
2003-05-04 5:38 ` Rob Browning
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=87issrlhyh.fsf@zip.com.au \
--to=user42@zip.com.au \
/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).