Invert GMLscripts.com

bit_set

Returns a bitfield with a given bit set to 1.

bits = 229;              //  bits == 229 [ 11100101 ]
bits = bit_set(bits, 4); //  bits == 245 [ 11110101 ]
bit_set(bitfield, bit)
Returns a bitfield with a given bit set to 1.
COPY/// @func   bit_set(bitfield, bit)
///
/// @desc   Returns a bitfield with a given bit set to 1.
///
/// @param  {real}      bitfield    integer or group of bits
/// @param  {real}      bit         bit index to set
///
/// @return {real}      bitfield with bit set
///
/// GMLscripts.com/license

function bit_set(bitfield, bit)
{
    return bitfield | (1 << bit);
}

Contributors: xot

GitHub: View · Commits · Blame · Raw