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

floor — Round values toward negative infinity in MATLAB and RunMat.

floor(X) rounds each element of X toward negative infinity, returning the greatest integer less than or equal to each input value.

Syntax

Y = floor(X)

Inputs

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

Returns

NameTypeDescription
YNumericArrayRounded output values.

Errors

IdentifierWhenMessage
RunMat:floor:InvalidInputInput cannot be interpreted as numeric, logical, char, or complex data.floor: invalid input
RunMat:floor:InvalidArgumentArgument count does not match supported floor invocation forms.floor: invalid argument
RunMat:floor:InternalInternal tensor conversion/allocation/provider interaction failed.floor: internal error

How floor works

  • Works on scalars, vectors, matrices, and higher-dimensional tensors with MATLAB broadcasting semantics.
  • All eight integer classes are exact class-preserving identity operations, including integer variables inside tables and timetables.
  • Logical inputs are promoted to doubles (false → 0, true → 1) before flooring.
  • Character arrays are interpreted numerically (their Unicode code points) and return dense double tensors.
  • Complex inputs are floored component-wise: floor(a + bi) = floor(a) + i·floor(b).
  • Non-finite values (NaN, Inf, -Inf) propagate unchanged.
  • Empty arrays return empty arrays of the appropriate shape.

Does RunMat run floor 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 unary_floor hook when available; otherwise RunMat gathers, computes with matching host precision, and uploads the result back to that same provider. Logical tensors promote to double and are likewise restored to the owner.

GPU memory and residency

G = gpuArray([1.8 -0.2; 2.7 3.4]);
result = gather(floor(G));

Expected output:

result =
    [ 1 -1;
      2  3]

Examples

Flooring positive and negative scalars

x = [-2.7, -0.3, 0, 0.8, 3.9];
y = floor(x)

Expected output:

y = [-3, -1, 0, 0, 3]

Flooring every element of a matrix

A = [1.2 4.7; -3.4 5.0];
B = floor(A)

Expected output:

B = [1 4; -4 5]

Flooring fractions stored in a tensor

t = reshape([-1.8, -0.2, 0.4, 1.9, 2.1, 3.6], [3, 2]);
floored = floor(t)

Expected output:

floored =
    [-2  1;
     -1  2;
      0  3]

Flooring complex numbers component-wise

z = [1.7 + 2.1i, -0.2 - 3.9i];
result = floor(z)

Expected output:

result = [1 + 2i, -1 - 4i]

Keeping GPU data on device when the provider supports unary_floor

G = gpuArray([1.8 -0.2 0.0; -1.1 2.5 -3.4]);
floored = floor(G);
H = gather(floored)

Expected output:

H =
    [ 1 -1  0;
     -2  2 -4]

Using floor with coding agents

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

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

FAQ

Does floor always round toward negative infinity?⌄

Yes—positive values round down toward zero, while negative values round to the more negative integer (e.g., floor(-0.1) = -1).

How are complex numbers handled?⌄

The real and imaginary parts are floored independently, matching MATLAB's component-wise definition.

What happens with logical arrays?⌄

Logical values promote to doubles (0 or 1) before flooring, so the outputs remain 0 or 1.

Can I pass character arrays to floor?⌄

Yes. Character data is treated as its numeric code points, producing a double tensor of the same size.

Do NaN and Inf values change?⌄

No. Non-finite inputs propagate unchanged.

Will GPU execution change floating-point results?⌄

No. Providers implement IEEE-compliant flooring; when a provider lacks unary_floor, RunMat falls back to the CPU to preserve MATLAB-compatible behaviour.

Can fusion keep floor on the GPU?⌄

Yes. floor participates in elementwise fusion, so fused graphs can stay resident on the device when supported.

What does floor do in MATLAB?⌄

floor(X) rounds each element of X toward negative infinity. For example, floor(2.7) returns 2 and floor(-2.3) returns -3.

What is the difference between floor and fix in MATLAB?⌄

floor rounds toward negative infinity, while fix rounds toward zero. For positive numbers the result is the same, but for negative numbers they differ: floor(-2.7) returns -3, while fix(-2.7) returns -2.

Does floor work with GPU arrays in RunMat?⌄

Yes. RunMat automatically accelerates floor on the GPU with elementwise fusion support. Supported precisions include f32 and f64 with MATLAB-compatible broadcasting.

Related Math functions

Rounding

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

  • View the source for floor 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 floor works
  • Does RunMat run floor on the GPU?
  • GPU memory and residency
  • Examples
  • Flooring positive and negative scalars
  • Flooring every element of a matrix
  • Flooring fractions stored in a tensor
  • Flooring complex numbers component-wise
  • Keeping GPU data on device when the provider supports unary_floor
  • Using floor 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