- Joined
- Dec 12, 2008
- Messages
- 7,385
JASS:
/************************************************
*
* RightShift
* v1.1.1.0
* By Magtheridon96
*
* - Used to perform the bitwise RIGHTSHIFT
* operation for 8 bits. (1 byte)
*
* API:
* ----
*
* function B_RIGHTSHIFT takes integer byte, integer n returns integer
* - Returns (byte >> n)
* - The arguments must be in the range [0x00 ... 0xff]
* - The return value will be in the range [0x00 ... 0xff]
*
* function B_RIGHTSHIFT_CARRY takes integer byte, integer n returns integer
* - Returns the bits lost in (x) after (x >> n) is performed.
* - B_RIGHTSHIFT_CARRY(0x5, 2) = 0x1
* - B_RIGHTSHIFT_CARRY(0x5, 3) = 0x5
*
************************************************/
library RightShift
function B_RIGHTSHIFT_CARRY takes integer byte, integer n returns integer
return byte - byte / GetPowerOfTwo(n) * GetPowerOfTwo(n)
endfunction
function B_RIGHTSHIFT takes integer byte, integer n returns integer
return byte / GetPowerOfTwo(n)
endfunction
endlibrary
Yes, just another Bitwise operation snippet.
Nothing much to say really.
Feel free to comment, I guess..
Last edited: