Anonymous user
Bitwise operations: Difference between revisions
→{{header|J}}: Added functions to complete expanded requirements.
(→{{header|C}}: small correction) |
(→{{header|J}}: Added functions to complete expanded requirements.) |
||
Line 158:
=={{header|J}}==
Actual bitwise calculation occurs in<tt> bwo</tt>. Other definitions provide formatting.
bwo =: 17 b.
bwotxt =: title"_ combine bwo
combine =: [ ,. ":@|:@,:@]
title=: t,>;._2'Left shift:|Right shift:|Right signed shift:|Left rotate:|Right rotate:|'
f
Examples of execution, with output:
1 _251 _252 254 _8160 134217720 _8 _8129 268435448
Bitwise x AND y:
Bitwise x OR y:
Bitwise x XOR y:
Bitwise NOT-x:
Left shift:
Right shift: 134217720
........................x.x.x.x.▼
Right signed shift: _8
........................xxxxxxxx▼
Left rotate: _8129
Right rotate: 268435448
xxxxxxxxxxxxxxxxxxxxxxxx........▼
f _255 bwo 5 NB. 32-bit diagram
xxxxxxxxxxxxxxxxxxxxxxxx.....x.x
xxxxxxxxxxxxxxxxxxx.......x.....
.....xxxxxxxxxxxxxxxxxxxxxxxx...
xxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
xxxxxxxxxxxxxxxxxxx.......xxxxxx
....xxxxxxxxxxxxxxxxxxxxxxxxx...
=={{header|Java}}==
|