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: new lognot Date: Tue, 26 Aug 2003 08:11:39 +1000 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <87ad9xbd5w.fsf@zip.com.au> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1061871238 25283 80.91.224.253 (26 Aug 2003 04:13:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 26 Aug 2003 04:13:58 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Aug 26 06:13:56 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19rVDQ-0005SA-00 for ; Tue, 26 Aug 2003 06:13:56 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19rVCv-0005rK-2r for guile-devel@m.gmane.org; Tue, 26 Aug 2003 00:13:25 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19rVB0-0004vZ-69 for guile-devel@gnu.org; Tue, 26 Aug 2003 00:11:26 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19rV8G-0003LW-JJ for guile-devel@gnu.org; Tue, 26 Aug 2003 00:09:07 -0400 Original-Received: from [61.8.0.36] (helo=snoopy.pacific.net.au) by monty-python.gnu.org with esmtp (Exim 4.20) id 19rV6o-0002gq-Tu for guile-devel@gnu.org; Tue, 26 Aug 2003 00:07:07 -0400 Original-Received: from sunny.pacific.net.au (sunny.pacific.net.au [203.2.228.40]) by snoopy.pacific.net.au (8.12.3/8.12.3/Debian-6.4) with ESMTP id h7PMC50J026924 for ; Tue, 26 Aug 2003 08:12:05 +1000 Original-Received: from wisma.pacific.net.au (wisma.pacific.net.au [210.23.129.72]) by sunny.pacific.net.au with ESMTP id h7PMC5kv016120 for ; Tue, 26 Aug 2003 08:12:05 +1000 (EST) Original-Received: from localhost (ppp74.dyn228.pacific.net.au [203.143.228.74]) by wisma.pacific.net.au (8.12.9/8.12.9) with ESMTP id h7PMBoos012885 for ; Tue, 26 Aug 2003 08:11:59 +1000 (EST) Original-Received: from gg by localhost with local (Exim 3.35 #1 (Debian)) id 19rPYq-0000mo-00; Tue, 26 Aug 2003 08:11:40 +1000 Original-To: guile-devel@gnu.org Mail-Copies-To: never User-Agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.3 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2710 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2710 I'd like to suggest the rewrite below for lognot. I think it'd be a good thing if lognot behaved like logand etc and accepted only integers. The current use of scm_difference means a flonum or complex will work, but they're really not sensible operands. The use of mpz_com is a bit more direct too, though in fact it won't be much different speed-wise from mpz_sub. SCM_DEFINE (scm_lognot, "lognot", 1, 0, 0, (SCM n), "Return the integer which is the ones-complement of the integer\n" "argument.\n" "\n" "@lisp\n" "(number->string (lognot #b10000000) 2)\n" " @result{} \"-10000001\"\n" "(number->string (lognot #b0) 2)\n" " @result{} \"-1\"\n" "@end lisp") #define FUNC_NAME s_scm_lognot { if (SCM_INUMP (n)) { /* No overflow here, just need to toggle all the bits making up the inum. Enhancement: No need to unpack and put a new tag etc, could just xor a block of 1 bits. */ return SCM_MAKINUM (~ SCM_INUM (n)); } else if (SCM_BIGP (n)) { SCM result = scm_i_mkbig (); mpz_com (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (n)); scm_remember_upto_here_1 (n); return result; } else { SCM_WRONG_TYPE_ARG (SCM_ARG1, n); } } #undef FUNC_NAME _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel