bit shifting

Ian Piumarta piumarta at prof.inria.fr
Wed Apr 15 11:53:33 UTC 1998


> The problem might be a missing pair of parentheses in

Whoa, forget that.  I've not had enough coffee today -- precedence does
the right thing.

But this method *is* to blame.  Copy the block and replace self with -1
and arg with 1 and print it: answer -1.

How about this instead:

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

which seems to produce the right answers across a range of values.

Ian





More information about the Squeak-dev mailing list