RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

RunMat® is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
See all docs
Builtin Reference
    • bi2de
    • bin2dec
    • de2bi
    • dec2bin
    • dec2hex
    • hex2dec

bi2de — Convert base-P digit rows to decimal values.

bi2de(B) interprets each row of a real numeric or logical digit array as one base-2 number. The first column holds the least significant digit by default. Specify a base P and/or 'left-msb' to change the interpretation.

Syntax

D = bi2de(B)
D = bi2de(B, flg)
D = bi2de(B, P)
D = bi2de(B, P, flg)

Inputs

B
Type
Any
Required
Yes
Description
Real numeric or logical digit row/vector/matrix.
flg
Type
StringScalar
Required
Yes
Default
'right-msb'
Description
Digit order: right-msb or left-msb.
P
Type
NumericScalar
Required
Yes
Default
2
Description
Integer base at least two.
NameTypeRequiredDefaultDescription
BAnyYes—Real numeric or logical digit row/vector/matrix.
flgStringScalarYes'right-msb'Digit order: right-msb or left-msb.
PNumericScalarYes2Integer base at least two.

Returns

D
Type
NumericArray
Description
One decimal value for each digit row.
NameTypeDescription
DNumericArrayOne decimal value for each digit row.

Errors

RunMat:bi2de:InvalidInput
When
B is not a real numeric/logical 2-D digit array, or a digit is invalid.
Message
bi2de: B must contain valid real digits
RunMat:bi2de:InvalidBase
When
P is not an integer scalar at least two.
Message
bi2de: P must be an integer greater than 1
RunMat:bi2de:InvalidOrder
When
The digit order is not right-msb or left-msb.
Message
bi2de: unsupported digit order
IdentifierWhenMessage
RunMat:bi2de:InvalidInputB is not a real numeric/logical 2-D digit array, or a digit is invalid.bi2de: B must contain valid real digits
RunMat:bi2de:InvalidBaseP is not an integer scalar at least two.bi2de: P must be an integer greater than 1
RunMat:bi2de:InvalidOrderThe digit order is not right-msb or left-msb.bi2de: unsupported digit order
RunMat:bi2de:ExactRangeA converted result exceeds the exact supported decimal range.bi2de: result exceeds the maximum exact integer supported by RunMat
RunMat:bi2de:ProviderErrorGathering a resident digit matrix fails after admission.bi2de: failed to gather resident digits

Digits, shape, and class

A row vector produces one scalar. Each row of a matrix produces one element of a column vector. The default base is two and the default order is 'right-msb'; 'left-msb' makes the first column most significant.

Digits must be finite nonnegative integers less than P. Results above 2^52 reject rather than pass through an inexact decimal conversion. Double and logical inputs produce double values; single input produces single. Integer input retains its class if the result fits and otherwise widens within the same signedness.

Execution

Digit validation and conversion run on the host; the operation is a fusion boundary and does not use a GPU kernel. RunMat mode can gather a GPU-resident digit matrix after admission. MATLAB-compatible mode rejects that form before provider access.

A fixed-width integer base P is a RunMat extension. MATLAB-compatible mode accepts the documented single/double numeric base. Neither form reads the workspace, invokes callbacks, performs I/O, nor depends on time or randomness.

Examples

Convert default right-MSB digits

d = bi2de([1 0 1 0])

Expected output:

d = 5

Read the first column as most significant

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

Expected output:

d = 10

Convert two base-3 digit rows

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

Expected output:

d = [21; 5]

Keep an integer result's class

d = bi2de(uint8([1 0 1]))

Expected output:

d = uint8(5)

Reject a digit outside the base

bi2de([1 2])

Compile digit conversion and error handling

B = [1 0 1; 0 1 1]; D = bi2de(B); L = bi2de([1 0 1 0],'left-msb'); caught = false; try; bad = bi2de([1 2]); catch failure; caught = strcmp(failure.identifier,'RunMat:bi2de:InvalidInput'); end

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 digit ordering?⌄

'right-msb'. The first column is least significant unless you pass 'left-msb'.

Can bi2de convert bases other than two?⌄

Yes. Pass an integer base P of at least two, such as bi2de(B,3).

What happens if the decimal result is too large?⌄

The conversion rejects results above 2^52 rather than silently losing exactness.

Related Comms functions

Conversion

bin2dec · de2bi · dec2bin · dec2hex · hex2dec

Modulation

pskmod · qammod

Source you can read

Every RunMat function's source is public. Read exactly how bi2de is executed, line by line, in Rust.

  • View the source for bi2de in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • Digits, shape, and class
  • Execution
  • Examples
  • Convert default right-MSB digits
  • Read the first column as most significant
  • Convert two base-3 digit rows
  • Keep an integer result's class
  • Reject a digit outside the base
  • Compile digit conversion and error handling
  • Using bi2de with coding agents
  • FAQ
  • Related Comms functions
  • Conversion
  • Modulation
  • Source you can read
  • About RunMat