bitxor - Bitwise XOR

Syntax

C = bitxor(A, B)

Description

C = bitxor(A, B) returns the bitwise XOR of arguments A and B, where A and B are unsigned integers or arrays of unsigned integers.

Examples

Example 1

The five-bit binary representations of the integers 13 and 27 are 01101 and 11011, respectively. Performing a bitwise XOR on these numbers yields 10110, or 22.

C = bitxor(uint8(13), uint8(27))
C =
    22

Example 2

Create a truth table for a logical XOR operation:

A = uint8([0 1; 0 1]);
B = uint8([0 0; 1 1]);

TT = bitxor(A, B)
TT =
    0    1
    1    0

See Also

bitand, bitcmp, bitget, bitmax, bitor, bitset, bitshift

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS