dec2hex — Convert decimal integers to hexadecimal character rows in MATLAB and RunMat.

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

Syntax

dec2hex(D)

How dec2hex works

  • D may be numeric, integer, logical, character, or gpuArray numeric data.
  • Double inputs must be finite integer values.
  • 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 F 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, fractional, and unsupported input values raise an error.

Examples

Convert a scalar decimal value

s = dec2hex(1023)

Expected output:

s = '3FF'

Pad to a minimum width

s = dec2hex(1023, 6)

Expected output:

s = '0003FF'

Convert multiple values to padded rows

s = dec2hex([1023 122 14])

Expected output:

s = ['3FF'; '07A'; '00E']

Format a negative value as two's complement

s = dec2hex(-16)

Expected output:

s = 'F0'

Using dec2hex with coding agents

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

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

FAQ

Are fractional inputs accepted?

No. RunMat requires finite integer values for dec2hex.

Are hexadecimal letters uppercase?

Yes. RunMat emits uppercase A through F characters.

Conversion

bi2de · bin2dec · de2bi · dec2bin · hex2dec

Modulation

pskmod · qammod

Open-source implementation

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