all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Douglas Lewan <d.lewan2000@gmail.com>
To: Gregory Heytings <ghe@sdf.org>
Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Re: Bit shift oddity?
Date: Mon, 19 Oct 2020 11:19:20 -0400	[thread overview]
Message-ID: <e11d2022-2a9f-64ca-4898-b27f32d29331@gmail.com> (raw)
In-Reply-To: <alpine.NEB.2.22.394.2010191119450453.14045@sdf.lonestar.org>

Nice. Thank you.

On 10/19/20 5:23 AM, Gregory Heytings wrote:
>
>>
>> I see the following:
>>
>>   ELISP> (= (lsh -1 (lognot 0)) (lsh -2 (lognot 0)))
>>
>>   t
>>
>>   ELISP> (= (lsh -1 (lognot 0)) (lsh -3 (lognot 0)))
>>
>>   nil
>>
>> The first seems odd to me. Is it really what's expected?
>>
>
> Yes, it's what is expected.  The docstring of lsh says:
>
> "(lsh VALUE COUNT) ... If COUNT is negative, shifting is actually to 
> the right. In this case, if VALUE is a negative fixnum treat it as 
> unsigned ..."
>
> -1 (decimal) = 111...111 (binary)
> -2 (decimal) = 111...110 (binary)
>
> If you shift these two numbers to the right, you get the exact same 
> result: 011...111, that is, `most-positive-fixnum'.

-- 
,Doug
d.lewan2000@gmail.com
(908) 720 7908

You know, it's amazing how much closer to 0 that 8 067 332 is than 15 is. (2020 Oct 18)




      reply	other threads:[~2020-10-19 15:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-19  0:19 Bit shift oddity? Douglas Lewan
2020-10-19  7:06 ` tomas
2020-10-19  7:48   ` Douglas Lewan
2020-10-19  9:01     ` tomas
2020-10-19 15:14       ` Stefan Monnier
2020-10-19 15:30         ` tomas
2020-10-19  9:23 ` Gregory Heytings via Users list for the GNU Emacs text editor
2020-10-19 15:19   ` Douglas Lewan [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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e11d2022-2a9f-64ca-4898-b27f32d29331@gmail.com \
    --to=d.lewan2000@gmail.com \
    --cc=ghe@sdf.org \
    --cc=help-gnu-emacs@gnu.org \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.