Bitwise operations: Difference between revisions
Content deleted Content added
→{{header|Python}}: 2**n - 1 as mask function |
|||
Line 638: | Line 638: | ||
=={{header|Smalltalk}}== |
=={{header|Smalltalk}}== |
||
{{incorrect|Smalltalk}} |
|||
Since [[GNU Smalltalk]] by default runs without a graphical user interface, I wrote the program in that dialect. The actual methods for bitwise operations (''bitAnd:'', etc.) are the same in all implementations. |
Since [[GNU Smalltalk]] by default runs without a graphical user interface, I wrote the program in that dialect. The actual methods for bitwise operations (''bitAnd:'', etc.) are the same in all implementations. |
||
<lang smalltalk>| testBitFunc | |
|||
<pre> |
|||
testBitFunc := [ :a :b | |
|||
a := stdin nextLine asInteger. |
|||
('%1 and %2 is %3' % { a. b. (a bitAnd: b) }) displayNl. |
|||
b := stdin nextLine asInteger. |
|||
(' |
('%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. |
|||
</pre> |
|||
]. |
|||
testBitFunc value: 16r7F value: 4 .</lang> |
|||
=={{header|Visual Basic .NET}}== |
=={{header|Visual Basic .NET}}== |
||
<lang vb>Sub Test(a as Integer, b as Integer) |
<lang vb>Sub Test(a as Integer, b as Integer) |