fix
Rounds toward zero, discarding the fractional part.
Category: Language Fundamentals > Operators and Elementary Operations
Syntax
Y = fix(X)
Rounds each element of X: toward zero.
Description
fix truncates: positive numbers behave like floor and negative numbers like ceil, so fix(2.7) is 2 and fix(-2.7) is -2.
It matches the result of integer division in languages that truncate, and rem(a,b) equals a - b*fix(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
fix([2.7 -2.7 0.5 -0.5])
fix(-7/2)
Output
ans = 1×4
2 -2 0 0
ans = -3