bit_clear
Returns a bitfield with a given bit cleared to 0.
bits = 229; // bits == 229 [ 11100101 ]
bits = bit_clear(bits, 5); // bits == 197 [ 11000101 ]
- bit_clear(bitfield, bit)
- Returns a bitfield with a given bit cleared to 0.
COPY/// @func bit_clear(bitfield, bit)
///
/// @desc Returns a bitfield with a given bit cleared to 0.
///
/// @param {real} bitfield integer or group of bits
/// @param {real} bit bit index to clear
///
/// @return {real} bitfield with bit cleared
///
/// GMLscripts.com/license
function bit_clear(bitfield, bit)
{
return bitfield & ~(1 << bit);
}
Contributors: xot
GitHub: View · Commits · Blame · Raw