prime:bitwise

This shows you the differences between two versions of the page.

Both sides previous revision Previous revision | |||

prime:bitwise [2017/12/04 03:13] webmasterpdx |
prime:bitwise [2017/12/04 23:16] (current) webmasterpdx |
||
---|---|---|---|

Line 1: | Line 1: | ||

+ | ====== Bitwise Manipulation on the HP Prime. ====== | ||

+ | |||

+ | BITSR(X) and BITSL(X,n) shift right and left respectively. The second argument says how much to shift. If not specified, it shifts only one position. Rotation and carry are not supported by default. Neither is bit test or selection. However, BITAND, BITNOT, BITOR and BITXOR are supported. BITNOT only takes one argument and inverts the bits. The other functions take as many arguments as you like and the specified logical operation is performed between the bits in all the integers specified. | ||

+ | |||

+ | Here are a group of useful functions to provide more traditional support for bit manipulation. | ||

+ | |||

+ | < | ||

+ | EXPORT BITLIB() | ||

+ | BEGIN | ||

+ | END; | ||

+ | |||

+ | EXPORT BIT(X,N) // GET NTH BIT OF X | ||

+ | BEGIN // LS BIT IS 0 | ||

+ | | ||

+ | END; | ||

+ | |||

+ | EXPORT BITSRC(X,N) // BITSR WITH CARRY | ||

+ | BEGIN // SET C + RETURN SHIFTED | ||

+ | | ||

+ | | ||

+ | END; | ||

+ | |||

+ | EXPORT BITSLC(X,N) // BITSL WITH CARRY | ||

+ | BEGIN // SET C + RETURN SHIFTED | ||

+ | | ||

+ | | ||

+ | END; | ||

+ | |||

+ | EXPORT BITROR(X) // ROTATE RIGHT | ||

+ | BEGIN | ||

+ | | ||

+ | END; | ||

+ | |||

+ | EXPORT BITROL(X) // ROTATE LEFT | ||

+ | BEGIN | ||

+ | | ||

+ | END; | ||

+ | </ | ||

+ | |||

prime/bitwise.txt · Last modified: 2017/12/04 23:16 by webmasterpdx