bi2de — Convert rows of binary or base-p digits to decimal integers in MATLAB and RunMat.

bi2de(B) treats each row of B as one binary number and returns decimal values. The default digit order is 'right-msb', so the first column contains the least significant digit. bi2de(B, P) converts base-P digits, and the optional 'left-msb' flag makes the first column the most significant digit.

Syntax

bi2de(B)

How bi2de works

  • B may be a scalar, vector, logical array, or 2-D numeric matrix.
  • For matrix inputs, each row is converted independently and the result is a column vector.
  • P must be an integer greater than one.
  • Every digit must be a finite nonnegative integer in the range [0, P-1].
  • 'right-msb' is the default and interprets column 1 as the least significant digit.
  • 'left-msb' interprets column 1 as the most significant digit.
  • Results that exceed RunMat's exact integer range are rejected instead of silently losing precision.

Examples

Default right-MSB binary conversion

d = bi2de([1 0 1 0])

Expected output:

d = 5

Left-MSB binary conversion

d = bi2de([1 0 1 0], 'left-msb')

Expected output:

d = 10

Convert rows of a base-3 matrix

d = bi2de([2 1 0; 0 1 2], 3, 'left-msb')

Expected output:

d = [21; 5]

Using bi2de with coding agents

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

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

FAQ

What is the default bit ordering?

'right-msb', matching MATLAB's Communications Toolbox default. The leftmost column is the least significant digit unless you pass 'left-msb'.

Does bi2de support bases other than two?

Yes. Pass the base as P, for example bi2de(B, 3) for ternary digits.

Conversion

bin2dec · de2bi · dec2bin · dec2hex · hex2dec

Modulation

pskmod · qammod

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how bi2de 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.