bit shifting
sqrmax at cvtci.com.ar
sqrmax at cvtci.com.ar
Sun Apr 12 19:12:30 UTC 1998
Hi.
>has anybody else discovered that bit shifting of negative numbers is
>broken? Although the comment in Integer>>bitShift: says that it shifts
>the two's complement, it's actually doing one's complement shifting,
>i.e.
> (-1 bitShift: 1) = -2
>which is plain wrong.
Well, yes... it shifts the integer but leaves the sign alone. I stumbled
into this dividing negative numbers by shifting right. A bad thing to do...
>Unfortunately, if I correct the
>SmallInteger>>bitShift: method, LargeInteger division breaks. And I
>don't want to mess with Integer>>digitDiv:neg: !
Hmmm... I'll check that. To my surprise, I've found that here Squeak can
only perform about 500 LargeInteger (>32 bits) bitAnd: per second. Some of us
here are preparing a package with speedups mainly to the arithmetic. We will
be posting it when we finish it. We already have some improvements for
fractions: #+, #*, #raisedToInteger:, #timesTwoPower:, etc; and some others for
Integers, particularly factorial related methods.
Andres.
More information about the Squeak-dev
mailing list
|