RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

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.

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

dec2bin — Convert decimal integers to binary character rows in MATLAB and RunMat.

dec2bin(D) converts each element of D to one binary character row. dec2bin(D, minDigits) pads each row to at least minDigits characters. Numeric arrays are processed in column-major element order and produce one output row per element.

Syntax

dec2bin(D)

How dec2bin works

  • D may be numeric, integer, logical, character, or gpuArray numeric data.
  • Double inputs are floored before conversion, matching MATLAB dec2bin behavior.
  • Nonnegative values are padded with 0 characters.
  • Negative values are represented using the smallest signed two's-complement storage width that can contain the value, with additional padding using 1 characters.
  • Signed integer inputs preserve their source integer storage width for negative two's-complement output.
  • minDigits must be a finite nonnegative integer scalar.
  • Outputs larger than RunMat's character-output safety limit are rejected before formatting.
  • Complex, non-finite, and unsupported input values raise an error.

Examples

Convert a scalar decimal value

s = dec2bin(23)

Expected output:

s = '10111'

Pad to a minimum width

s = dec2bin(23, 8)

Expected output:

s = '00010111'

Convert multiple values to padded rows

s = dec2bin([1023 122 14])

Expected output:

s = ['1111111111'; '0001111010'; '0000001110']

Format a negative value as two's complement

s = dec2bin(-16)

Expected output:

s = '11110000'

Using dec2bin with coding agents

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

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

FAQ

Does dec2bin round fractional inputs?⌄

No. RunMat floors fractional double inputs before conversion, following MATLAB dec2bin behavior.

How are negative numbers represented?⌄

Negative values are emitted as two's-complement binary rows using 8, 16, 32, or 64 bits as needed.

Related Comms functions

Conversion

bi2de · bin2dec · de2bi · dec2hex · hex2dec

Modulation

pskmod · qammod

Open-source implementation

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

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

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.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • How dec2bin works
  • Examples
  • Convert a scalar decimal value
  • Pad to a minimum width
  • Convert multiple values to padded rows
  • Format a negative value as two's complement
  • Using dec2bin with coding agents
  • FAQ
  • Related Comms functions
  • Conversion
  • Modulation
  • Open-source implementation
  • About RunMat