Bitwise operations: Difference between revisions
Content added Content deleted
(→{{header|J}}: Segregated bitwise and rotation/shift functions. Simplified verb 'combine'.) |
(→{{header|J}}: Fixed damage inadvertantly done to examples.) |
||
Line 224: | Line 224: | ||
f=: (32#2)&#: { '.x'"_ |
f=: (32#2)&#: { '.x'"_ |
||
Examples of execution, with output: |
Examples of execution, with output: |
||
_255 bwo 5 NB. numeric output of bitwise operations |
|||
1 _251 _252 254 |
|||
_255 brs 5 NB. numeric output of boolean rotation and shift operations |
|||
_8160 134217720 _8 _8129 268435448 |
|||
8160 7 7 8160 _134217721 |
|||
_255 boolf 5 NB. formatted text with English titling |
|||
Bitwise x AND y: |
Bitwise x AND y: 1 |
||
Bitwise x OR y: |
Bitwise x OR y: _251 |
||
Bitwise x XOR y: |
Bitwise x XOR y: _252 |
||
Bitwise NOT-x: |
Bitwise NOT-x: 254 |
||
Left shift: |
Left shift: _8160 |
||
Right shift: |
Right shift: 134217720 |
||
Right signed shift: |
Right signed shift: _8 |
||
Left rotate: |
Left rotate: _8129 |
||
Right rotate: |
Right rotate: 268435448 |
||
f _255 (bwo, brs) 5 NB. 32-bit diagrams |
f _255 (bwo, brs) 5 NB. 32-bit diagrams |
||
...............................x |
...............................x |