This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.



C = bitor(A,B)
C = bitor(A,B,assumedtype)
objout = bitor(netobj1,netobj2)



C = bitor(A,B) returns the bit-wise OR of A and B.


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

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


collapse all

Create a truth table for the logical OR operation.

A = uint8([0 1; 0 1]);
B = uint8([0 0; 1 1]);
TTable = bitor(A, B)
TTable = 2x2 uint8 matrix

   0   1
   1   1

bitor returns 1 if either bit-wise input is 1.

Explore how bitor handles negative values.

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

C = -5;
D = 6;
ans = -1

Input Arguments

collapse all

Input values, specified as scalars, vectors, matrices, or multidimensional arrays. Inputs A and B must either be the same size or have sizes that are compatible (for example, A is an M-by-N matrix and B is a scalar or 1-by-N row vector). For more information, see Compatible Array Sizes for Basic Operations. 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

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.

Data Types: char | string

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

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

Output Arguments

collapse all

Bit-wise OR 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.

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

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced before R2006a