Programmer Guide/Command Reference/INT: Difference between revisions

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
==INT==
<var>var</var> := INT <var>expression</var>
var>var</var> := INTCHECK <var>expression</var>


<code><var>var</var> := INT <var>expression</var></code>
The <code>INT</code> statement will cause your expression being evaluated as an integer expression. More precisely (more precisely less wrongly), the expression will be evaluated numerically, and the result will be converted to an integer whose textual representation will be the string to be assigned to the destination variable. The calculation itself will be done with the point floating, though (see the below examples for what that means).


<code><var>var</var> := INTCHECK <var>expression</var></code>
Note that the <code>INT</code> statement converts the result to an integer by ''truncating'' it. There is no rounding involved, no rounding at all.


-> var = evaluation result as an integer
In case of the expression being syntactically ill-formed, an error (<code>INT</code>) or warning (<code>INTCHECK</code>) is reported.


Evaluate a numeric expression and assign the scalar result. Please note that the expression is calculated in double precision before being converted to an integer. Integer conversion is of the 'cut-off' variety. E.g. <code>3.9</code> -> <code>3</code>. If the expression is syntactically ill-formed, an error (<code>INT</code>) or warning (<code>INTCHECK</code>) is reported.
See also: [[Programmer Guide/Command Reference/NUM|NUM]], [[Programmer Guide/Command Reference/EVAL|EVAL]]
 
See also: [[Programmer Guide/Command Reference/NUM|NUM]], EVAL


<pre>
<pre>

Revision as of 12:30, 31 March 2011

var := INT expression
var>var := INTCHECK expression

The INT statement will cause your expression being evaluated as an integer expression. More precisely (more precisely less wrongly), the expression will be evaluated numerically, and the result will be converted to an integer whose textual representation will be the string to be assigned to the destination variable. The calculation itself will be done with the point floating, though (see the below examples for what that means).

Note that the INT statement converts the result to an integer by truncating it. There is no rounding involved, no rounding at all.

In case of the expression being syntactically ill-formed, an error (INT) or warning (INTCHECK) is reported.

See also: NUM, EVAL

#int := int 3.1                    // == 3
#int := int 3.9                         // == 3
#int := int 3.9 * 3.9           // == 15
#int := int int(3.9) * int(3.9) // == 9

Navigation menu

Personal tools