From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.bugs Subject: bug#14916: Fixnum procedures can be made to return non-fixnums Date: Wed, 22 Jun 2016 11:32:14 -0400 Message-ID: <87por9s0ht.fsf@netris.org> References: <8738r9ai62.fsf@industria.weinholt.se> <87ioz5gffz.fsf@tines.lan> <87y580vjj1.fsf@industria.weinholt.se> <87shw73t47.fsf@pobox.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1466609665 11461 80.91.229.3 (22 Jun 2016 15:34:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 22 Jun 2016 15:34:25 +0000 (UTC) Cc: =?UTF-8?Q?G=C3=B6ran?= Weinholt , 14916@debbugs.gnu.org To: Andy Wingo Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Wed Jun 22 17:34:14 2016 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bFkAK-0003Ny-78 for guile-bugs@m.gmane.org; Wed, 22 Jun 2016 17:34:08 +0200 Original-Received: from localhost ([::1]:59136 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFkAJ-00046y-E6 for guile-bugs@m.gmane.org; Wed, 22 Jun 2016 11:34:07 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFk9K-0002Ka-QD for bug-guile@gnu.org; Wed, 22 Jun 2016 11:33:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFk9G-00066h-1j for bug-guile@gnu.org; Wed, 22 Jun 2016 11:33:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38991) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFk9F-00066d-UX for bug-guile@gnu.org; Wed, 22 Jun 2016 11:33:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bFk9F-0005jV-QQ for bug-guile@gnu.org; Wed, 22 Jun 2016 11:33:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Wed, 22 Jun 2016 15:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14916 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 14916-submit@debbugs.gnu.org id=B14916.146660955422004 (code B ref 14916); Wed, 22 Jun 2016 15:33:01 +0000 Original-Received: (at 14916) by debbugs.gnu.org; 22 Jun 2016 15:32:34 +0000 Original-Received: from localhost ([127.0.0.1]:51328 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFk8o-0005iq-24 for submit@debbugs.gnu.org; Wed, 22 Jun 2016 11:32:34 -0400 Original-Received: from world.peace.net ([50.252.239.5]:48073) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFk8m-0005ie-TF for 14916@debbugs.gnu.org; Wed, 22 Jun 2016 11:32:33 -0400 Original-Received: from c-73-253-48-168.hsd1.ma.comcast.net ([73.253.48.168] helo=jojen) by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1bFk8g-0005IX-SY; Wed, 22 Jun 2016 11:32:26 -0400 In-Reply-To: <87shw73t47.fsf@pobox.com> (Andy Wingo's message of "Tue, 21 Jun 2016 09:20:56 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.95 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:8128 Archived-At: Andy Wingo writes: > Hi Mark, > > I know you like mathy things and so this might be a project you would > like. I think the right thing to do here is to redefine fixnum? as > > (= x (logand x #x2fffffff)) This doesn't work for negative fixnums, because you are effectively masking out the sign of 'x' above. Unfortunately, this problem cannot be fixed by changing the mask. For purposes of the bitwise operations, negative integers are treated as though they have an infinite number of ones in the high bits, e.g. -1 is all ones, and is thus an identity for 'logand'. So, there's no single sign bit, but rather an infinite number of them, and all of those bits can also be used as value bits as well, so there's no way to avoid masking out the sign without also masking out high-order value bits. One possibility would be to subtract 'most-negative-fixnum' from x before masking, but I don't know what the compiler would do with that. Mark