You are currently viewing the gmlscripts.pro static mirror. Forum access and script submissions are not available through this mirror.

Invert gmlscripts.pro

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 number with bits in reverse order.
COPY/// bitwise_reverse8(n)
//
//  Returns the given number with bits in reverse order.
//
//      n           8-bit integer, real
//
/// gmlscripts.pro/license
{
    var n;
    n = argument0;
    n = (n & $55) <<  1 | (n & $AA) >>  1;
    n = (n & $33) <<  2 | (n & $CC) >>  2;
    n = (n & $0F) <<  4 | (n & $F0) >>  4;
    return n;
}

Contributors: xot

GitHub: View · Commits · Blame · Raw