Programmer Guide/Command Reference/NUM: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 15: Line 15:
::;hexa-decimal numbers:<code>0x1234, 0xabc, 0XabC</code>
::;hexa-decimal numbers:<code>0x1234, 0xabc, 0XabC</code>
::;special constants:<code>pi</code> (=3.1415...), <code>e</code> (=2.71828...),  
::;special constants:<code>pi</code> (=3.1415...), <code>e</code> (=2.71828...),  
:::<code>rand</code> (a linear distributed pseudo random number ''r'' with: -1 &le; ''r'' < 1)
:::<code>rand</code> (a linear distributed pseudo random number ''r''; -1&le;''r''&lt;1)
:::<code>lran</code> (a linear distributed pseudo random number ''r'' with: 0 &le; ''r'' &lt;)
:::<code>lran</code> (a linear distributed pseudo random number ''r''; 0&le;''r''&lt;1)
::;numerical operators:<code>-''a''</code> (negate), <code>''a''+''b''</code> (add), <code>''a''-''b''</code> (subtract), <code>''a''*''b''</code> (multiply), <code>''a''/''b''</code> (divide), <code>''a''%''b''</code> (modulo), <code>''a''^''b'' (power)</code>
::;numerical operators:<code>-''a''</code> (negate), <code>''a''+''b''</code> (add), <code>''a''-''b''</code> (subtract), <code>''a''*''b''</code> (multiply), <code>''a''/''b''</code> (divide), <code>''a''%''b''</code> (modulo), <code>''a''^''b'' (power)</code>
::;logical operators (bitwise): <code>!''a</code> (not), <code>''a''&''b''</code> (and), <code>''a''|''b''</code> (or), <code>''a''^''b''</code> (exclusive or)
::;logical operators (bitwise): <code>!''a</code> (not), <code>''a''&''b''</code> (and), <code>''a''|''b''</code> (or), <code>''a''^''b''</code> (exclusive or)
Line 22: Line 22:
::;functions:
::;functions:
::{class="einrahmen"
::{class="einrahmen"
|<code>setlran(''seed'')</code>linear distributed pseudo random number ''r'' (0&le;''r''&lt;1)<BR>''seed'' is the start value (0&le;''seed''&lt<1)
|
|
|-
|}
_T("RAND"), _T("LRAN"), _T("SETLRAN"), _T("SIN"), _T("COS"), // 00-04
_T("TAN"), _T("ASIN"), _T("ACOS"), _T("ATAN"), _T("EXP"), // 05-09
_T("LOG"), _T("LN"), _T("SQRT"), _T("ABS"), _T("INT"), // 10-14
_T("ROUND"), _T("DB"), _T("SINX"), _T("SINC"), _T("SIGN"), //  15-19
_T("HZ2BARK"), _T("BARK2HZ"), _T("BIT"), _T("FLOOR"), _T("ISERR"), // 20-24
_T("ISERROR"), _T("ISWARNING"),_T("ISWARN"), _T("NPOW2"),





Revision as of 09:59, 26 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) will be returned. The expression may consist of the following parts:
decimal numbers
123.456, 17.5e3, 100, -312.123, 1e-3
hexa-decimal numbers
0x1234, 0xabc, 0XabC
special constants
pi (=3.1415...), e (=2.71828...),
rand (a linear distributed pseudo random number r; -1≤r<1)
lran (a linear distributed pseudo random number r; 0≤r<1)
numerical operators
-a (negate), a+b (add), a-b (subtract), a*b (multiply), a/b (divide), a%b (modulo), a^b (power)
logical operators (bitwise)
!a (not), a&b (and), a|b (or), a^b (exclusive or)
brackets
(expression)
functions
{class="einrahmen"

|setlran(seed)linear distributed pseudo random number r (0≤r<1)
seed is the start value (0≤seed&lt<1) | |- |}

_T("RAND"), _T("LRAN"), _T("SETLRAN"), _T("SIN"), _T("COS"), // 00-04 _T("TAN"), _T("ASIN"), _T("ACOS"), _T("ATAN"), _T("EXP"), // 05-09 _T("LOG"), _T("LN"), _T("SQRT"), _T("ABS"), _T("INT"), // 10-14 _T("ROUND"), _T("DB"), _T("SINX"), _T("SINC"), _T("SIGN"), // 15-19 _T("HZ2BARK"), _T("BARK2HZ"), _T("BIT"), _T("FLOOR"), _T("ISERR"), // 20-24 _T("ISERROR"), _T("ISWARNING"),_T("ISWARN"), _T("NPOW2"),



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