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

fix — Round values toward zero in MATLAB and RunMat.

fix(X) removes the fractional part of each element by rounding toward zero. Positive values behave like floor, negative values behave like ceil, and complex values are processed component-wise. Input coercions and array-shape behavior follow MATLAB semantics.

Syntax

Y = fix(X)

Inputs

NameTypeRequiredDefaultDescription
XAnyYes—Numeric, logical, or complex input array.

Returns

NameTypeDescription
YNumericArrayRounded values toward zero.

Errors

IdentifierWhenMessage
RunMat:fix:InvalidInputInput cannot be interpreted as numeric, logical, or complex data.fix: invalid input
RunMat:fix:InternalInternal tensor conversion or allocation failed.fix: internal error

How fix works

  • fix rounds positive inputs down toward zero and negative inputs up toward zero.
  • All eight integer classes are exact class-preserving identity operations. Logical inputs are promoted to double before rounding.
  • Complex numbers are rounded component-wise (fix(a + bi) = fix(a) + i·fix(b)), matching MATLAB.
  • NaN, Inf, and -Inf propagate unchanged.
  • Character arrays are treated as their numeric code points and return dense double tensors.
  • Empty arrays return empty arrays with identical shape.

Does RunMat run fix on the GPU?

Resident integer tensors are returned as exact identity operations without floating conversion or a new allocation. Floating tensors use the owning provider's optional unary_fix hook when available; otherwise RunMat gathers, computes with matching host precision, and uploads the result back to that same provider. Logical tensors follow the promotion-to-double path and are likewise restored to the owner.

GPU memory and residency

G = gpuArray(linspace(-2.4, 2.4, 6));
truncGpu = fix(G);
hostValues = gather(truncGpu);

Expected output:

hostValues = [-2 -1 0 0 1 2];

Examples

Truncating positive and negative values toward zero

values = [-3.7 -2.4 -0.6 0 0.6 2.4 3.7];
truncated = fix(values)

Expected output:

truncated = [-3 -2 0 0 0 2 3]

Removing fractional parts from a matrix

A = [1.9  4.1; -2.8  0.5];
B = fix(A)

Expected output:

B = [1 4; -2 0]

Keeping GPU residency when kernels are available

G = gpuArray(linspace(-2.4, 2.4, 6));
truncGpu = fix(G);
hostValues = gather(truncGpu)

Expected output:

hostValues = [-2 -1 0 0 1 2]

Dropping fractional parts of complex numbers

z = [1.9 + 2.6i, -3.4 - 0.2i];
fixed = fix(z)

Expected output:

fixed = [1 + 2i, -3 + 0i]

Converting character arrays to truncated numeric codes

letters = ['A' 'B' 'C'];
codes = fix(letters)

Expected output:

codes = [65 66 67]

Using fix with coding agents

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

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

FAQ

How is fix different from floor and ceil?⌄

fix always rounds toward zero. Positive numbers behave like floor, negatives behave like ceil. Use floor or ceil when you specifically want to round toward negative or positive infinity.

What happens to existing integers?⌄

Typed integer inputs preserve their exact class, shape, and values. Logical inputs are different: they promote to double values of 0 or 1.

Does fix change NaN or Inf values?⌄

No. NaN, Inf, and -Inf propagate unchanged.

How are complex numbers handled?⌄

fix rounds the real and imaginary components independently, exactly like MATLAB.

Will fix stay on the GPU?⌄

Yes. Resident integer inputs retain their original handle. Floating and logical fallback results are uploaded back to the input's owning provider when a native kernel is unavailable.

Related Math functions

Rounding

ceil · floor · mod · rem · round

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 fix is executed, line by line, in Rust.

  • View the source for fix 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 fix works
  • Does RunMat run fix on the GPU?
  • GPU memory and residency
  • Examples
  • Truncating positive and negative values toward zero
  • Removing fractional parts from a matrix
  • Keeping GPU residency when kernels are available
  • Dropping fractional parts of complex numbers
  • Converting character arrays to truncated numeric codes
  • Using fix 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