Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

bitxor

Syntax

  • objout = bitxor(netobj1,netobj2)

Description

example

C = bitxor(A,B) returns the bit-wise XOR of A and B.

example

C = bitxor(A,B,assumedtype) assumes that A and B are of assumedtype.

objout = bitxor(netobj1,netobj2) returns the bit-wise XOR of the .NET enumeration objects netobj1 and netobj2.

Examples

collapse all

Truth Table

Create a truth table for the logical XOR operation.

A = uint8([0 1; 0 1]);
B = uint8([0 0; 1 1]);
TTable = bitxor(A, B)
TTable =

    0    1
    1    0

bitxor returns 0 if both bit-wise inputs are equal.

Negative Values

Explore how bitxor handles negative values.

MATLAB® encodes negative integers using two's complement. Thus, the bit-wise XOR of -5 (11111010) and 6 (00000110) is -3 (11111100).

C = -5;
D = 6;
bitxor(C,D,'int8')
ans =

    -3

Related Examples

Input Arguments

collapse all

A,B — Input valuesscalars | vectors | matrices | multidimensional arrays

Input values, specified as scalars, vectors, matrices, or multidimensional arrays. Inputs A and B must be the same size unless one is a scalar. A scalar value is expanded to be the same size as the other array. A and B also must be the same data type unless one is a scalar double.

  • If A and B are double arrays, and assumedtype is not specified, then MATLAB® treats A and B as unsigned 64-bit integers.

  • If assumedtype is specified, then all elements in A and B must have integer values within the range of assumedtype.

Data Types: double | logical | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

assumedtype — Assumed data type of A and B'uint64' | 'uint32' | 'uint16' | 'uint8' | 'int64' | 'int32' | 'int16' | 'int8'

Assumed data type of A and B, specified as 'uint64', 'uint32', 'uint16', 'uint8', 'int64', 'int32', 'int16', or 'int8'.

  • If A and B are double arrays, then assumedtype can specify any valid integer type, but defaults to 'uint64'.

  • If A and B are integer type arrays, then assumedtype must specify that same integer type.

netobj1, netobj2 — Input values.NET enumeration objects

Input values, specified as .NET enumeration objects. You must be running a version of Windows® to use .NET enumeration objects as input arguments.

bitxor is an instance method for MATLAB enumeration objects created from a .NET enumeration.

Output Arguments

collapse all

C — Bit-wise XOR resultarray

Bit-wise XOR result, returned as an array. C is the same data type as A and B.

  • If either A or B is a scalar double, and the other is an integer type, then C is the integer type.

objout — Bit-wise XOR result.NET enumeration object

Bit-wise XOR result, returned as a .NET enumeration objects.

Introduced before R2006a

Was this topic helpful?