bitor
Bit-wise OR of integers.
Category: Language Fundamentals > Operators and Elementary Operations
Syntax
C = bitor(A, B)
Bit-wise OR of the binary representations of A and B.
Description
Each bit of the result is 1 when the corresponding bit is 1 in at least one operand. It is used to switch bits on or to combine flags stored in one integer: bitor(flags, 4) sets the third bit.
Unlike |, which treats operands as true or false, bitor works on the individual binary digits.
Input arguments
A, B- Arrays of nonnegative integers (doubles must be integer-valued, up to 2^53) or integer types of the same class. Sizes must be compatible.
Output arguments
C- Array with the combined bits, of the same class as the inputs.
Example
bitor(12, 10)
bitor(5, [1 2 8])
bitor(uint8(1), uint8(6))
Output
ans = 14
ans = 1×3
5 7 13
ans = uint8
7