[squeak-dev] Bit operators (was: Is anyone else running a 64-bit
image on a regular basis?)
Bert Freudenberg
bert at freudenbergs.de
Mon Sep 8 18:50:41 UTC 2014
On 08.09.2014, at 19:44, David T. Lewis <lewis at mail.msen.com> wrote:
>> On 08.09.2014, at 18:28, Bert Freudenberg <bert at freudenbergs.de> wrote:
>>
>>> https://github.com/bertfreudenberg/SqueakJS/commit/6d694d0733
>>
>> Yikes. I just spotted another bug in that function. Can you see it, too?
>
> I think it should be using an unsigned right shift like this:
>
> if ((shifted>>>shiftCount) === smallInt) return shifted;
>
> Dave
No, "bitShift:" is supposed to be signed. This is my test if the result still fits in 32 bits, by reversing the shift. I *think* that part is correct ;)
E.g.
-55 << 5 ==> -1760
-1760 >> 5 ==> -55
meaning we can use the result but
-555555555 << 5 ==> -597908576
-597908576 >> 5 ==> -18684643
so we cannot use the result because bits got dropped.
- Bert -
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4142 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140908/4e48f7ba/smime.bin
More information about the Squeak-dev
mailing list
|