Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
10
Task/Bitwise-operations/Smalltalk/bitwise-operations-1.st
Normal file
10
Task/Bitwise-operations/Smalltalk/bitwise-operations-1.st
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
| testBitFunc |
|
||||
testBitFunc := [ :a :b |
|
||||
('%1 and %2 is %3' % { a. b. (a bitAnd: b) }) displayNl.
|
||||
('%1 or %2 is %3' % { a. b. (a bitOr: b) }) displayNl.
|
||||
('%1 xor %2 is %3' % { a. b. (a bitXor: b) }) displayNl.
|
||||
('not %1 is %2' % { a. (a bitInvert) }) displayNl.
|
||||
('%1 left shift %2 is %3' % { a. b. (a bitShift: b) }) displayNl.
|
||||
('%1 right shift %2 is %3' % { a. b. (a bitShift: (b negated)) }) displayNl.
|
||||
].
|
||||
testBitFunc value: 16r7F value: 4 .
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
(a bitClear: b) "mask out bits"
|
||||
(a bitAt: index) "retrieve a bit (bit-index, one-based)"
|
||||
(a setBit: index) "set a bit (bit-index)"
|
||||
(a clearBit: index) "clear a bit (bit-index)"
|
||||
(a invertBit: index) "invert a bit (bit index)"
|
||||
lowBit "find the index of the lowest one-bit; zero if none"
|
||||
highBit "find the index of the highest one-bit; zero if none"
|
||||
bitCount "count the one-bits"
|
||||
Loading…
Add table
Add a link
Reference in a new issue