[Pkg] The Trunk: Kernel-nice.402.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Feb 16 09:08:44 UTC 2010
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.402.mcz
==================== Summary ====================
Name: Kernel-nice.402
Author: nice
Time: 16 February 2010, 10:08:26.271 am
UUID: 804739fb-f633-4d4d-9717-2b69cea9c2cb
Ancestors: Kernel-ar.401
Naive implementation of Integer>>bitAt:put:
=============== Diff against Kernel-ar.401 ===============
Item was added:
+ ----- Method: Integer>>bitAt:put: (in category 'bit manipulation') -----
+ bitAt: anInteger put: value
+ "Answer a new Integer that has the bit of rank anInteger set to value.
+ The bit value should be 0 or 1, otherwise raise an Error.
+ The bits are indexed starting at 1 for the least significant bit.
+ For negative integers, operate on 2-complement representation."
+
+ | b |
+ b := self bitAt: anInteger.
+ b = value ifTrue: [^self].
+ 0 = value ifTrue: [^self bitAnd: (1 bitShift: anInteger - 1) bitInvert].
+ 1 = value ifTrue: [^self bitOr: (1 bitShift: anInteger - 1)].
+ self error: 'bit value should be 0 or 1'!
More information about the Packages
mailing list