unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Andy Wingo <wingo@pobox.com>
Cc: "Göran Weinholt" <goran@weinholt.se>, 14916@debbugs.gnu.org
Subject: bug#14916: Fixnum procedures can be made to return non-fixnums
Date: Wed, 22 Jun 2016 11:32:14 -0400	[thread overview]
Message-ID: <87por9s0ht.fsf@netris.org> (raw)
In-Reply-To: <87shw73t47.fsf@pobox.com> (Andy Wingo's message of "Tue, 21 Jun 2016 09:20:56 +0200")

Andy Wingo <wingo@pobox.com> 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





      reply	other threads:[~2016-06-22 15:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-20  5:56 bug#14916: Fixnum procedures can be made to return non-fixnums Göran Weinholt
2013-08-17  3:32 ` Mark H Weaver
2013-08-17  7:55   ` Göran Weinholt
2016-06-21  7:20     ` Andy Wingo
2016-06-22 15:32       ` Mark H Weaver [this message]

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=87por9s0ht.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=14916@debbugs.gnu.org \
    --cc=goran@weinholt.se \
    --cc=wingo@pobox.com \
    /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).