Programmer Guide/Command Reference/NUM: Difference between revisions

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
No edit summary
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:NUM, NUMCHECK}}
==NUM==
{|class="einrahmen"
!command !!return value !!value of RC
|-
|<code>NUM <var>expression</var></code>
|value of ''expression'' or<BR>empty string if the evaluation fails
|0<BR>error code
|-
|<code>NUMCHECK <var>expression</var></code>
|value of ''expression'' or<BR>empty string if the evaluation fails
|0<BR>warning code
|}
;Description: The ''expression'' will be evaluated numerically, and the result (textual representation) is the return value. The following operators and functions are available.


<code><var>var</var> := NUM <var>expression</var></code>


<code><var>var</var> := NUMCHECK <var>expression</var></code>


-> var = evaluation result as a double number


Evaluate a numeric expression and assign the result to <var>var</var>. If the expression is syntactically ill-formed, an error (<code>NUM</code>) or warning (<code>NUMCHECK</code>) is reported.
;Notes:
:* The <code>INT</code> command 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 (<code>INT</code>) or warning (<code>INTCHECK</code>) is reported.
;See also: [[../NUM|NUM, NUMCHECK]], [[../EVAL|EVAL, EVALCHECK]]
 
 
;Examples:
#result := int 3.1          // #result is set to 3
#result := int 3.9          // #result is set to 3, too
#result := int 3.9 * 3.9    // #result is set to 15 (note that calculation
                              // is done in floating point, resulting in 15.21,
                              // and truncation occurs only on assigning
// compare the preceding example with the following one:
#result := int 3 * int(3.9)  // here, #result will be assigned 9 - cool, isn't it?

Revision as of 14:36, 21 April 2011

command return value value of RC
NUM expression value of expression or
empty string if the evaluation fails
0
error code
NUMCHECK expression value of expression or
empty string if the evaluation fails
0
warning code
Description
The expression will be evaluated numerically, and the result (textual representation) is the return value. The following operators and functions are available.



Notes
  • The INT command 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, NUMCHECK, EVAL, EVALCHECK


Examples
#result := int 3.1           // #result is set to 3
#result := int 3.9           // #result is set to 3, too
#result := int 3.9 * 3.9     // #result is set to 15 (note that calculation
                             // is done in floating point, resulting in 15.21,
                             // and truncation occurs only on assigning
// compare the preceding example with the following one:
#result := int 3 * int(3.9)  // here, #result will be assigned 9 - cool, isn't it?

Navigation menu

Personal tools