Programmer Guide/Command Reference/EVAL/int: Difference between revisions

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
No edit summary
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
=====int=====
Convert elements of argument <var>x</var> to integer. This function is implemented in two versions. The result is always of the same type as the argument <var>x</var>.


An integer
Note: The values of <var>x</var> must be in the range of a 32bit signed integer!
----
;Usage 1: <code>int(<var>x</var>)</code>
:;<var>x</var>: a scalar, vector or matrix
;Result 1: Has the same type as ''x'', but the elements are converted to integer. The fractional part is truncated.
----
;Usage 2: <code>int(<var>x</var>, <var>flag</var>)</code>
:;<var>x</var>: a scalar, vector or matrix
:;<var>flag</var>: selects if the values are truncated (''flag''&ne;1) or rounded (''flag''=1); ''flag'' must be a scalar
;Result 2: Has the same type as ''x'', but the elements are rounded or truncated according to the value of ''flag''.
----
;See also: [[../round|round]], [[../floor|floor]], [[../sign|sign]]


=====Usage:=====
[[../#Functions|<function list>]]
 
<code>int(<var>x</var>)</code>
 
=====Function:=====
 
The integer part of the <var>x</var>
 
=====Usage:=====
 
<code>int(<var>x</var>,1)</code>
 
=====Function:=====
 
The rounded integer part of <var>x</var> (= int(<var>x</var> + 1/2))

Latest revision as of 11:01, 21 April 2011

Convert elements of argument x to integer. This function is implemented in two versions. The result is always of the same type as the argument x.

Note: The values of x must be in the range of a 32bit signed integer!


Usage 1
int(x)
x
a scalar, vector or matrix
Result 1
Has the same type as x, but the elements are converted to integer. The fractional part is truncated.

Usage 2
int(x, flag)
x
a scalar, vector or matrix
flag
selects if the values are truncated (flag≠1) or rounded (flag=1); flag must be a scalar
Result 2
Has the same type as x, but the elements are rounded or truncated according to the value of flag.

See also
round, floor, sign

<function list>

Navigation menu

Personal tools