Name
bit_xor
Synopsis
void bit_xor(const unsigned char *bits1
, const unsigned char *bits2
, unsigned char *bitsx
, intsize
);
Return Value
None.
Description
Computes the bitwise XOR (exclusive OR) of the two buffers
bits1
and
bits2
, each containing
size
bits, and returns the result in
bitsx
. The bitwise XOR of two binary
operands yields in each position i of the
result where in position i of the operands
the bits are the same, and 1 in each position where the bits are
different. For example, 11010 ⊕ 01011 = 10001 (⊕ denotes XOR). It is the responsibility
of the caller to manage the storage required by
bitsx
.
Complexity
O (β), where β is the number of bits in each buffer.
Get Mastering Algorithms with C now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.