unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* logcount negatives
@ 2003-05-03 23:37 Kevin Ryde
  2003-05-04  0:15 ` Marius Vollmer
  2003-05-04  5:38 ` Rob Browning
  0 siblings, 2 replies; 3+ messages in thread
From: Kevin Ryde @ 2003-05-03 23:37 UTC (permalink / 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: logcount negatives
  2003-05-03 23:37 logcount negatives Kevin Ryde
@ 2003-05-04  0:15 ` Marius Vollmer
  2003-05-04  5:38 ` Rob Browning
  1 sibling, 0 replies; 3+ messages in thread
From: Marius Vollmer @ 2003-05-04  0:15 UTC (permalink / raw)
  Cc: guile-devel

Kevin Ryde <user42@zip.com.au> writes:

> A small fix for logcount on negatives,

Kevin Ryde <user42@zip.com.au> writes:

> A small bug in integer-length, [...]

Please apply, when Rob doesn't object.

Thanks!

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: logcount negatives
  2003-05-03 23:37 logcount negatives Kevin Ryde
  2003-05-04  0:15 ` Marius Vollmer
@ 2003-05-04  5:38 ` Rob Browning
  1 sibling, 0 replies; 3+ messages in thread
From: Rob Browning @ 2003-05-04  5:38 UTC (permalink / raw)
  Cc: guile-devel

Kevin Ryde <user42@zip.com.au> writes:

> 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.

Looks good to me.

Thanks

-- 
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592  F9A0 25C8 D377 8C7E 73A4


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-05-04  5:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-03 23:37 logcount negatives Kevin Ryde
2003-05-04  0:15 ` Marius Vollmer
2003-05-04  5:38 ` Rob Browning

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).