User Tools

Site Tools


prime:bitwise

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
prime:bitwise [2017/12/03 19:14]
webmasterpdx
prime:bitwise [2017/12/04 23:16] (current)
webmasterpdx
Line 5: Line 5:
 Here are a group of useful functions to provide more traditional support for bit manipulation. Here are a group of useful functions to provide more traditional support for bit manipulation.
  
 +<​code>​
 +EXPORT BITLIB()
 +BEGIN
 +END;
  
 +EXPORT BIT(X,N) // GET NTH BIT OF X
 +BEGIN // LS BIT IS 0
 + ​RETURN BITSR(X,​N); ​
 +END;
 +
 +EXPORT BITSRC(X,N) // BITSR WITH CARRY
 +BEGIN // SET C + RETURN SHIFTED
 + ​C:​=BITSR(X,​N-1);​
 + ​RETURN BITSR(X,N);
 +END;
 +
 +EXPORT BITSLC(X,N) // BITSL WITH CARRY
 +BEGIN // SET C + RETURN SHIFTED
 + ​C:​=BITSR(BITSL(X,​N-1),​GETBITS(X)-1);​
 + ​RETURN BITSL(X,​N); ​
 +END;
 +
 +EXPORT BITROR(X) // ROTATE RIGHT
 +BEGIN
 + ​RETURN BITSR(X,​1)+BITSL(X,​GETBITS(X)-1);​
 +END;
 +
 +EXPORT BITROL(X) // ROTATE LEFT
 +BEGIN
 + ​RETURN BITSL(X,​1)+BITSR(X,​GETBITS(X)-1);​
 +END;
 +</​code>​
  
  
prime/bitwise.1512357277.txt.gz · Last modified: 2017/12/03 19:14 by webmasterpdx