bit_xor
lib callCapy
function bit_xor(a : s8, b : s8) s8 function bit_xor(a : s16, b : s16) s16 function bit_xor(a : s32, b : s32) s32 function bit_xor(a : s64, b : s64) s64 function bit_xor(a : u8, b : u8) u8 function bit_xor(a : u16, b : u16) u16 function bit_xor(a : u32, b : u32) u32 function bit_xor(a : u64, b : u64) u64
Description
bit_xor() toggles the bits of a that are set in b. Applying the same mask twice restores the original.
Parameters
a : the first integer
b : the second integer, in the same type
Return Values
An integer with a bit set where exactly one input has it, in their type.
Example
Capy
var flags := u8(6) print(bit_xor(flags, u8(4)), " ", bit_xor(bit_xor(flags, u8(4)), u8(4)), "\n")
Output
2 6