bitwise_reverse8
Returns the given 8-bit number with bits in reverse order.
bits = 123; // 123 [ 01111011 ]
rev = bitwise_reverse8(bits); // 222 [ 11011110 ]
- bitwise_reverse8(n)
- Returns the given 8-bit integer with bits in reverse order.
COPY/// @func bitwise_reverse8(n)
///
/// @desc Returns the given 8-bit integer with bits in reverse order.
///
/// @param {real} n 8-bit integer
///
/// @return {real} given integer with bits reversed
///
/// GMLscripts.com/license
function bitwise_reverse8(n)
{
n = (n & 0x55) << 1 | (n & 0xAA) >> 1;
n = (n & 0x33) << 2 | (n & 0xCC) >> 2;
n = (n & 0x0F) << 4 | (n & 0xF0) >> 4;
return n;
}
Contributors: xot
GitHub: View · Commits · Blame · Raw