bitor — Compute bitwise OR for integer-valued scalars and arrays.

bitor(A, B) applies bitwise OR to finite nonnegative integer-valued inputs using MATLAB-style implicit expansion.

Syntax

C = bitor(A, B)

Inputs

NameTypeRequiredDefaultDescription
ANumericArrayYesLeft integer-valued input.
BNumericArrayYesRight integer-valued input.

Returns

NameTypeDescription
CNumericArrayBitwise numeric result.

Errors

IdentifierWhenMessage
RunMat:bitwise:InvalidInputInputs are not finite integer-valued numeric, logical, or gatherable gpuArray values.bitwise operation: invalid input
RunMat:bitwise:SizeMismatchInput shapes are not compatible for implicit expansion.bitwise operation: array sizes are not compatible
RunMat:idivide:DivideByZeroThe divisor contains zero.idivide: division by zero
RunMat:idivide:OverflowA rounded quotient cannot be represented in the dividend integer class.idivide: quotient overflows output class

How bitor works

  • Accepts double integer-valued inputs, logical inputs, integer scalar values, integer-class tensors, and gatherable gpuArray tensors.
  • Supports implicit expansion across compatible shapes.
  • For mixed unsigned integer inputs, returns the widest unsigned integer class involved; double and logical inputs return double-compatible numeric results.
  • Rejects fractional, negative double, infinite, NaN, complex, string, cell, and struct inputs.

Does RunMat run bitor on the GPU?

RunMat currently executes integer bitwise functions on the host.

GPU memory and residency

GPU inputs are gathered for host execution.

Example

Scalar bitwise OR

bitor(5, 3)

Expected output:

ans = 7

Using bitor with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how bitor changes the result.

Run a small bitor example, explain the result, then change one input and compare the output.

FAQ

Does bitor preserve integer class?

For unsigned integer operands, the result keeps the widest unsigned integer class involved, so mixed uint8/uint32 inputs return uint32 regardless of argument order.

Bit

and · bitand · bitshift · not · or · xor

Rel

eq · ge · gt · isequal · isequaln · le · lt · ne

Logical

logical

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how bitor is executed, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.