cint
Closest integer function.
Syntax
cint(expr)
Argument
- expr
- A valid scalar, vector, or matrix expression.
Example
Templex Expression | Result |
---|---|
{cint(2.8)} |
3 |
{cint( {-1.1, 0.6, 1} )} |
-1, 1, 1 |
{cint( {{0.6, 1},{-.25, -1.4}} )} |
{ 1, 1 }, { 0, -1 } |
Comments
The cint function returns the integer nearest in magnitude to expr. Fractions greater than or equal to 0.5 are rounded up, others are rounded down.
If expr is a scalar, the result is a scalar. The result is the value of the closest integer function of expr.
If expr is a vector, the result is a vector of the same dimensions containing the value of the closest integer function of each element in expr.
If expr is a matrix, the result is a matrix of the same dimensions containing the value of the closest integer function of each element in expr.