bit shifting

Hans-Martin Mosner hm.mosner at cww.de
Thu Apr 16 20:25:04 UTC 1998


And again...

bit shifting negative numbers to the right was wrong... sigh...
This one works better.

Hans-Martin

Content-Type: text/plain; charset=us-ascii; x-mac-type="54455854"; x-mac-creator="4D505320"; name="SmallInteger-bitShift.st"
Content-Transfer-Encoding: 7bit
Content-Description: MPW Shell Document
Content-Disposition: inline; filename="SmallInteger-bitShift.st"

'From Squeak 1.21 of July 17, 1997 on 16 April 1998 at 10:17:13 pm'!

!SmallInteger methodsFor: 'bit manipulation' stamp: 'hmm 4/18/98 0-470'!
bitShift: arg 
	"Primitive. Answer an Integer whose value is the receiver's value shifted
	left by the number of bits indicated by the argument. Negative arguments
	shift right.
	Essential.  See Object documentation whatIsAPrimitive."

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





More information about the Squeak-dev mailing list