[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bit shift oddity?
From: |
Stefan Monnier |
Subject: |
Re: Bit shift oddity? |
Date: |
Mon, 19 Oct 2020 11:14:52 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> (ash shift (lognot 0))))))
Could there be a simple misunderstanding: the shift amount is the
*second* argument. Here you always pass (lognot 0), which is -1, so
it's a right shift by 1, IOW a kind of "divide by 2".
> shift=-1 res=-1
> shift=-2 res=-1
> shift=-3 res=-2
> shift=-4 res=-2
> shift=-5 res=-3
> shift=-6 res=-3
> shift=-7 res=-4
> shift=-8 res=-4
> shift=-9 res=-5
> shift=-10 res=-5
That does indeed look like divide by 2 to me (rounding toward -∞).
Stefan
Re: Bit shift oddity?, Gregory Heytings, 2020/10/19