From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.lisp.guile.devel Subject: logcount negatives Date: Sun, 04 May 2003 09:37:58 +1000 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <87issrlhyh.fsf@zip.com.au> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1052005234 1133 80.91.224.249 (3 May 2003 23:40:34 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 3 May 2003 23:40:34 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun May 04 01:40:30 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19C6cI-0000I5-00 for ; Sun, 04 May 2003 01:40:30 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19C6cH-000157-08 for guile-devel@m.gmane.org; Sat, 03 May 2003 19:40:29 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 19C6b0-0008OM-00 for guile-devel@gnu.org; Sat, 03 May 2003 19:39:10 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 19C6al-0007zB-00 for guile-devel@gnu.org; Sat, 03 May 2003 19:38:57 -0400 Original-Received: from snoopy.pacific.net.au ([61.8.0.36]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19C6a5-0007f3-00 for guile-devel@gnu.org; Sat, 03 May 2003 19:38:13 -0400 Original-Received: from sunny.pacific.net.au (sunny.pacific.net.au [203.2.228.40]) h43NcBs7029541 for ; Sun, 4 May 2003 09:38:12 +1000 Original-Received: from wisma.pacific.net.au (wisma.pacific.net.au [210.23.129.72]) by sunny.pacific.net.au with ESMTP id h43NcBQg001118 for ; Sun, 4 May 2003 09:38:11 +1000 (EST) Original-Received: from localhost (ppp30.dyn228.pacific.net.au [203.143.228.30]) by wisma.pacific.net.au (8.12.9/8.12.9) with ESMTP id h43NcAYZ026161 for ; Sun, 4 May 2003 09:38:10 +1000 (EST) Original-Received: from gg by localhost with local (Exim 3.35 #1 (Debian)) id 19C6Zr-0002yZ-00; Sun, 04 May 2003 09:37:59 +1000 Original-To: guile-devel@gnu.org User-Agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.2 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2254 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2254 --=-=-= 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. --=-=-= Content-Disposition: attachment; filename=numbers.c.logcount.diff --- 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); --=-=-= Content-Disposition: attachment; filename=numbers.test.logcount.diff --- 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)))))) --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel --=-=-=--