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

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact
  • License
  • Privacy

Learn

  • Docs
  • Blog
  • Benchmarks
  • RunMat vs MATLAB Online

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.

/
See all docs
Builtin Reference
    • ceil
    • fix
    • floor
    • mod
    • rem
    • round

round — Round values to nearest integers, decimal places, or significant digits with MATLAB-compatible modes.

round(X) rounds numeric values to the nearest integers using MATLAB-compatible half-away-from-zero behavior. Additional forms support rounding to decimal places or significant digits.

Syntax

Y = round(X)
Y = round(X, N)
Y = round(X, N, mode)

Inputs

NameTypeRequiredDefaultDescription
XAnyYes—Numeric, logical, or complex input values.
NNumericScalarNo0Digits for decimal-place rounding.
NNumericScalarYes—Digits argument.
modeStringScalarYes"decimals"Rounding mode ('decimals' or 'significant').

Returns

NameTypeDescription
YNumericArrayRounded output values.

Errors

IdentifierWhenMessage
RunMat:round:InvalidInputInput X cannot be interpreted as numeric/logical/complex data.round: invalid input
RunMat:round:InvalidArgumentArgument count does not match supported call forms.round: invalid argument
RunMat:round:InvalidDigitsN is not an integer scalar or violates mode constraints.round: invalid digits argument
RunMat:round:InvalidModemode is not a supported text token.round: invalid mode
RunMat:round:InternalInternal tensor conversion/allocation failed.round: internal error

How round works

  • round(X) rounds floating elements to the nearest integer with ties away from zero; integer arrays are returned unchanged with exact native class and storage.
  • round(X, N) rounds to N decimal digits when N is positive and to powers of ten when N is negative.
  • round(X, N, 'significant') rounds to N significant digits. N must be a positive integer.
  • Logical inputs are promoted to double before rounding; round(true) returns 1.
  • Complex inputs are rounded component-wise (round(a + bi) = round(a) + i·round(b)), matching MATLAB.
  • Non-finite values (NaN, Inf, -Inf) propagate unchanged regardless of precision arguments.
  • Character arrays are treated as their numeric code points and return double tensors of the same size.
  • The documented integer surface is the one-input identity form. Multi-input forms reject integer X. RunMat mode additionally accepts a typed-integer N for floating X, while strict MATLAB mode rejects that control extension; N is read exactly from native storage and must fit the supported signed range.

Does RunMat run round on the GPU?

For round(X), RunMat asks the input handle's owning provider for unary_round; RunMat-only digit-aware forms may ask that owner for round_digits. A missing hook triggers one owner-specific host gather, and any resident result path remains tied to the same provider.

GPU memory and residency

The MATLAB-compatible round(X) form stays resident when the input handle's owning provider exposes unary_round; integer gpuArray input is already integral and remains unchanged. RunMat-only digit-aware forms may use round_digits. Provider gaps gather through the owning provider before host execution.

Examples

Rounding values to the nearest integers

X = [-3.5 -2.2 -0.5 0 0.5 1.7];
Y = round(X)

Expected output:

Y = [-4 -2 -1 0 1 2]

Rounding to a fixed number of decimal places

temps = [21.456 19.995 22.501];
rounded = round(temps, 2)

Expected output:

rounded = [21.46 20.00 22.50]

Rounding to negative powers of ten

counts = [1234 5678 91011];
rounded = round(counts, -2)

Expected output:

rounded = [1200 5700 91000]

Rounding to significant digits

measurements = [0.001234 12.3456 98765];
sig3 = round(measurements, 3, 'significant')

Expected output:

sig3 = [0.00123 12.3 98800]

Rounding GPU tensors and gathering the results

G = gpuArray(linspace(-2.5, 2.5, 6));
rounded = round(G);
hostValues = gather(rounded)

Expected output:

hostValues = [-3 -2 -1 1 2 3]

Using round with coding agents

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

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

FAQ

Does round always round half values away from zero?⌄

Yes. MATLAB and RunMat both use half-away-from-zero semantics, so round(0.5) returns 1 and round(-0.5) returns -1.

Can I round to decimal places and significant digits?⌄

Yes. Use round(X, N) for decimal places and round(X, N, 'significant') for significant digits. Negative N values round to tens, hundreds, and so on.

What happens if I pass a non-integer N?⌄

N must be an integer scalar. RunMat raises a MATLAB-compatible error when N is not an integer or is non-finite.

How are complex numbers handled?⌄

RunMat rounds the real and imaginary components independently, matching MATLAB's component-wise behaviour.

Do NaN or Inf values change when rounded?⌄

No. Non-finite values propagate unchanged for every rounding mode, just like MATLAB.

Will rounding stay on the GPU?⌄

The MATLAB-compatible GPU form is round(X), which stays resident when the owning provider implements unary_round; an integer gpuArray is already integral and remains unchanged. Digit-aware forms are host/RunMat-extension paths and do not claim MATLAB gpuArray compatibility.

Can I round logical or character arrays?⌄

Yes. Logical values are converted to doubles (0 or 1) and characters are rounded as their numeric code points, returning dense double tensors.

What does round do in MATLAB?⌄

round(X) rounds each element of X to the nearest integer. round(X, N) rounds to N decimal places. Ties (e.g., 2.5) round away from zero.

What is the difference between round, floor, and ceil in MATLAB?⌄

round rounds to the nearest integer, floor rounds toward negative infinity, and ceil rounds toward positive infinity. For 2.5: round returns 3, floor returns 2, ceil returns 3.

Does round support GPU acceleration in RunMat?⌄

Yes. round runs on the GPU with elementwise fusion support. It accepts f32 and f64 precisions and supports MATLAB-compatible broadcasting.

Does MATLAB's round use banker's rounding?⌄

— No. MATLAB (and RunMat) round halves *away from zero*, not to even. So round(0.5) returns 1, round(-0.5) returns -1, round(2.5) returns 3, and round(3.5) returns 4. This differs from Python's built-in round and IEEE 754 default rounding, which both use banker's rounding (round-half-to-even). NumPy's np.round also uses banker's rounding, so ported code may give different results on .5 cases — use round(x) in MATLAB/RunMat when you specifically want half-away-from-zero.

How do I round to N decimal places?⌄

— Use round(X, N). Positive N rounds to digits to the right of the decimal point; negative N rounds to digits to the left. For example, round(pi, 3) returns 3.1416 and round(12345, -3) returns 12000. Use round(X, N, 'significant') when you want N significant digits instead of decimal places.

Related Math functions

Rounding

ceil · fix · floor · mod · rem

Elementwise

abs · angle · bsxfun · complex · conj · double · erf · erfcinv · exp · expm1 · factorial · flintmax · gamma · gammaln · heaviside · hypot · idivide · imag · intmax · intmin · ldivide · log · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · realmax · realmin · realsqrt · rescale · sign · single · sqrt · swapbytes · times · typecast · uint16 · uint32 · uint8

Trigonometry

acos · acosh · asin · asinh · atan · atan2 · atanh · cos · cosd · cosh · cospi · deg2rad · pol2cart · rad2deg · sin · sind · sinh · sinpi · tan · tand · tanh

Reduction

all · any · bounds · cummax · cummin · cumprod · cumsum · cumtrapz · diff · gradient · max · maxk · mean · median · min · mink · movmax · movmean · movmedian · movmin · movprod · movstd · movsum · movvar · nnz · prod · rms · std · sum · trapz · var

Structure

bandwidth · isdiag · ishermitian · issymmetric · istril · istriu · symrcm

Signal

blackman · butter · buttord · cheb2ord · conv · conv2 · deconv · downsample · envelope · filter · filtfilt · fir1 · freqz · gauspuls · hamming · hann · hilbert · periodogram · pulstran · pwelch · rectpuls · resample · sawtooth · sinc · spectrogram · square · tripuls · unwrap · upsample · zplane

Factor

chol · decomposition · eig · eigs · lu · qr · svd

Solve

cond · det · inv · linsolve · norm · null · pinv · rank · rcond · rref · vecnorm

Optim

coneprog · fminbnd · fminunc · fsolve · fzero · integral · linprog · lsqcurvefit · lsqnonlin · optimoptions · optimset · quad · secondordercone

Ops

cross · ctranspose · dot · mldivide · mpower · mrdivide · mtimes · pagemtimes · pagetranspose · trace · transpose

Symbolic

digits · int · limit · piecewise · sym · syms · vpa

Fft

fft · fft2 · fftn · fftshift · ifft · ifft2 · ifftn · ifftshift

Interpolation

griddedInterpolant · interp1 · interp1q · interp2 · pchip · ppval · spline

Discrete

lcm · primes

Ode

ode15s · ode23 · ode45

Poly

polyder · polyfit · polyint · polyval · roots

Open-source implementation

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

  • View the source for round 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
  • Inputs
  • Returns
  • Errors
  • How round works
  • Does RunMat run round on the GPU?
  • GPU memory and residency
  • Examples
  • Rounding values to the nearest integers
  • Rounding to a fixed number of decimal places
  • Rounding to negative powers of ten
  • Rounding to significant digits
  • Rounding GPU tensors and gathering the results
  • Using round with coding agents
  • FAQ
  • Related Math functions
  • Rounding
  • Elementwise
  • Trigonometry
  • Reduction
  • Structure
  • Signal
  • Factor
  • Solve
  • Optim
  • Ops
  • Symbolic
  • Fft
  • Interpolation
  • Discrete
  • Ode
  • Poly
  • Open-source implementation
  • About RunMat