Programmer Guide/Command Reference/EVAL/int: Difference between revisions
From STX Wiki
< Programmer Guide | Command Reference | EVAL
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 7: | Line 7: | ||
;Usage 1: '''<code>int(<var>x</var>)</code>''' | ;Usage 1: '''<code>int(<var>x</var>)</code>''' | ||
:;<var>x</var>: a scalar, vector or matrix | :;<var>x</var>: a scalar, vector or matrix | ||
;Result 1: | ;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>''' | ;Usage 2: '''<code>int(<var>x</var>, <var>flag</var>)</code>''' | ||
:;<var>x</var>: a scalar, vector or matrix | :;<var>x</var>: a scalar, vector or matrix | ||
:;<var>flag</var>: selects if the values are truncated (''flag''!=1) or rounded (''flag''==1); ''flag'' must be a scalar | :;<var>flag</var>: selects if the values are truncated (''flag''!=1) or rounded (''flag''==1); ''flag'' must be a scalar | ||
;Result 2: | ;Result 2: Has the same type as ''x'', but the elements are rounded (''flag''==1) or truncated (''flag''!=1). | ||
---- | ---- | ||
;See also: [[Programmer_Guide/Command_Reference/EVAL/round|round]], [[Programmer_Guide/Command_Reference/EVAL/floor|floor]], [[Programmer_Guide/Command_Reference/EVAL/sign|sign]] | ;See also: [[Programmer_Guide/Command_Reference/EVAL/round|round]], [[Programmer_Guide/Command_Reference/EVAL/floor|floor]], [[Programmer_Guide/Command_Reference/EVAL/sign|sign]] | ||
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]] | [[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]] |
Revision as of 11:57, 4 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 (flag==1) or truncated (flag!=1).