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/04 03:11]
webmasterpdx
prime:bitwise [2017/12/04 23:16]
webmasterpdx
Line 6: Line 6:
  
 <​code>​ <​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>​ </​code>​
  
  
prime/bitwise.txt · Last modified: 2017/12/04 23:16 by webmasterpdx