[squeak-dev] The Trunk: Kernel-cmm.568.mcz
Chris Muller
asqueaker at gmail.com
Wed Apr 13 15:55:29 UTC 2011
Cool, thanks!
Bert, I ridded the test of its time-constraint and included LargeIntegers.
On Tue, Apr 12, 2011 at 1:20 AM, Nicolas Cellier
<nicolas.cellier.aka.nice at gmail.com> wrote:
> Bit by bit ?
> I suggest using
> http://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel
> reverse next power of two bits, then bitShift: the difference...
>
> Or someone else will exhibit a bitBlt hack :)
>
> Nicolas
>
> 2011/4/12 <commits at source.squeak.org>:
>> 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
|