floor
Rounds toward negative infinity.
Category: Language Fundamentals > Operators and Elementary Operations
Syntax
Y = floor(X)
Rounds each element of X: toward negative infinity.
Description
floor returns the largest integer that is less than or equal to its argument. For negative numbers this moves away from zero: floor(-2.5) is -3, whereas fix(-2.5) is -2.
Combined with division, floor(a/b) gives the integer quotient, and a - b*floor(a/b) is mod(a,b).
Input arguments
X- Numeric array. For complex values the real and imaginary parts are processed separately. Integer types are returned unchanged.
Output arguments
Y- Array of the same size and class as
X, holding integer values.
Example
floor([1.8 -1.2 2 -2.5])
floor(10/3)
7 - 3*floor(7/3)
Output
ans = 1×4
1 -2 2 -3
ans = 3
ans = 1