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
Last revision Both sides next revision
prime:bitwise [2017/12/04 03:11]
webmasterpdx
prime:bitwise [2017/12/04 03:13]
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
 + LOCAL r;
 + ​C:​=BITSR(X,​N-1);​
 + ​r:​=BITSR(X,​N);​
 + ​RETURN r;
 +END;
 +
 +EXPORT BITSLC(X,N) // BITSL WITH CARRY
 +BEGIN // SET C + RETURN SHIFTED
 + LOCAL r;
 + ​C:​=BITSR(BITSL(X,​N-1),​GETBITS(X)-1);​
 + ​r:​=BITSL(X,​N);​
 + ​RETURN r; 
 +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