bit shifting

Ian Piumarta piumarta at prof.inria.fr
Wed Apr 15 11:38:37 UTC 1998


> Good question. The linux version responds with -1 too.

The problem might be a missing pair of parentheses in
SmallInteger>>bitShift:

	<primitive: 17>
		self < 0 ifTrue: [^ -1 - (-1-self bitShift: arg)].
		^ super bitShift: arg

which would make more sense as:

	<primitive: 17>
		self < 0 ifTrue: [^ -1 - ((-1 - self) bitShift: arg)].
		^ super bitShift: arg

(Prim 17 pops the receiver with #popPos32BitInteger, and so fails for
negative receivers.)

Ciao,

Ian





More information about the Squeak-dev mailing list