Post History
Bitwise operations (WIP) Befunge, rather pointedly, lacks bitwise ops. No shifts, no and, no or, no xor. Shifts Shifts can be implemented as multiplication and division by powers of two. Shifts...
Answer
#1: Initial revision
# Bitwise operations (WIP) Befunge, rather pointedly, lacks bitwise ops. No shifts, no and, no or, no xor. ## Shifts Shifts can be implemented as multiplication and division by powers of two. Shifts by arbitrary amounts can be done with successive multiplication/division by two. Rendered tricky by negatives, all shifts below are only functional with 31 bits and leave 32nd untouched. ### Shift by n #### Left shift ``` v v >1-\2*v ^_v#:\< $ v v ``` #### Right shift ``` v v >1-\2/v ^_v#:\< $ v v ``` #### Bidirectional shift (negative is right) Note: not particularly golfed. ``` v v >:0`#v_0-v v < v < >1-\2*v>1-\2\v ^_v#:\<^_v#:\< v < $ v v ```