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
_255 bwo 5 NB. numeric output of bitwise operations
5 255 250 _256
1 _251 _252 254
255 brs 5 NB. numeric output of boolean rotation and shift operations
_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
_255 boolf 5 NB. formatted text with English titling
Bitwise x AND y: 5
Bitwise x AND y: 1
Bitwise x OR y: 255
Bitwise x OR y: _251
Bitwise x XOR y: 250
Bitwise x XOR y: _252
Bitwise NOT-x: _256
Bitwise NOT-x: 254
Left shift: 8160
Left shift: _8160
Right shift: 7
Right shift: 134217720
Right signed shift: 7
Right signed shift: _8
Left rotate: 8160
Left rotate: _8129
Right rotate: _134217721
Right rotate: 268435448
f _255 (bwo, brs) 5 NB. 32-bit diagrams
f _255 (bwo, brs) 5 NB. 32-bit diagrams
...............................x
...............................x