[squeak-dev] The Trunk: Kernel-cmm.568.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Apr 12 02:04:25 UTC 2011


Chris Muller uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-cmm.568.mcz

==================== Summary ====================

Name: Kernel-cmm.568
Author: cmm
Time: 11 April 2011, 9:01:09.858 pm
UUID: 340ecdd9-40de-42e4-8388-09abc07cdedf
Ancestors: Kernel-nice.567

Added Integer>>bitReverse:.

=============== Diff against Kernel-nice.567 ===============

Item was added:
+ ----- Method: Integer>>bitReverse: (in category 'bit manipulation') -----
+ bitReverse: highBit 
+ 	"Reverse the bits of the receiver so that the lsb is the highBit'th bit of the answer.  Translated from C code at:  http://graphics.stanford.edu/~seander/bithacks.html#BitReverseObvious."
+ 	| v r s |
+ 	highBit < self highBit ifTrue: [ self error: 'Not enough bits.' ].
+ 	v := self.
+ 	r := v bitAnd: 1.
+ 	s := highBit - 1.
+ 	[ v := v bitShift: -1.
+ 	v = 0 ] whileFalse:
+ 		[ r := r bitShift: 1.
+ 		r := r bitOr: (v bitAnd: 1).
+ 		s := s - 1 ].
+ 	^ r bitShift: s!




More information about the Squeak-dev mailing list