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