Functions and Operators Available
Below is a list of functions and operators that are available for use in defining Expressions, String Expressions, Model Expressions, and Model String Expressions:
Note: Trigonometric functions are in radians.
Operators
Precedence Higher precedence operators are processed first |
Symbol |
Description |
Example |
0 |
OR |
OR |
(2 > 1) OR (2 > 3) = not zero* |
1 |
XOR |
XOR |
|
2 |
AND |
AND |
(2 > 1) AND (2 > 3) = 0* |
3 |
NOT |
NOT |
|
4 |
> |
Greater than |
9 > 2 = not zero* |
4 |
< |
Less than |
7 < 4 = 0* |
4 |
== |
Equal test |
5 == 4 = 0* |
4 |
>= |
Greater or equal |
3 >= 3 = not zero* |
4 |
<= |
Less or equal |
3 <= 9 = 0 |
4 |
<> |
Not equal |
12 <> 20 = not zero* |
5 |
bitor |
bitwise OR |
|
6 |
bitxor |
bitwise XOR |
|
7 |
bitand |
bitwise AND |
|
8 |
shl |
Shift Left |
|
8 |
shr |
Shift Right |
|
9 |
+ |
Add |
1 + 1 = 2 |
9 |
- |
Subtract |
9 - 5 = 4 |
10 |
* |
Multiply by |
3 * 6 = 18 |
10 |
/ |
Divide by |
9 / 2 = 4.5 |
10 |
\ |
Integer divide by |
9 \ 2 = 4 |
10 |
MOD |
Modulo (remainder) |
7 mod 4 = 3 |
11 |
bitnot |
||
11 |
! |
Factorial |
5! = 120 |
12 |
^ |
Raised to the power of |
4 ^ 5 = 1024 |
13 |
( ) |
Prioritizes an expression |
5*(1+1) = 10 |
Functions
Symbol |
Description |
Example |
IIF |
If condition |
IIf(1+1==2,4,5) = 4 |
ISTRUE Added in version 19, build on November 19, 2015 |
Returns 1 if the string entered is: T, TRUE, CONNECTED, CLOSED, YES, Y, or 1. Otherwise returns 0. |
IsTrue('Closed') = 1 |
MIN |
Minimum value |
min(10,3,27,15) = 3 |
MAX |
Maximum value |
max(1,9)=9 |
SIN |
Sine |
sin(3.14159265) = 0 |
COS |
Cosine |
cos(3.14159265) = -1 |
TAN |
Tangent |
tan(3.14159265) = 0 |
ASIN |
Arc sine |
asin(1) = 1.570 |
ACOS |
Arc cosine |
acos(-1) = 3.141 |
ATAN, ATN |
Arc tangent |
atan(0) = atn(0) = 0 |
SEC |
Secant |
sec(0) = 1 |
CSC |
Cosecant |
csc(1) = 1.18 |
COT |
Cotangent |
cot(1) = 0.642 |
SINH |
Hyperbolic sine |
sinh(3) = 10.01 |
COSH |
Hyperbolic cosine |
cosh(2) = 3.76 |
TANH |
Hyperbolic tangent |
tanh(1) = 0.76 |
COTH |
Hyperbolic cotangent |
coth(1) = 1.31 |
SECH |
Hyperbolic secant |
sech(0) = 1 |
CSCH |
Hyperbolic cosecant |
csch(1) = 0.85 |
ASINH |
Hyperbolic arc sine |
asinh(2) = 1.44 |
ACOSH |
Hyperbolic arc cosine |
acosh(9) = 2.89 |
ATANH |
Hyperbolic arc tangent |
atanh(.1) = 0.10 |
ACOTH |
Hyperbolic arc cotangent |
acoth(7) = 0.14 |
ASECH |
Hyperbolic arc secant |
asech(.3) = 1.87 |
ACSCH |
Hyperbolic arc cosecant |
acsch(2) = 0.48 |
ABS |
Absolute value |
abs(-8) = 8 |
EXP |
e to the power of |
exp(3) = 20.08 |
EXP2 |
2 to the power of |
exp2(3) = 8 |
EXP10 |
10 to the power of |
exp10(3) = 1000 |
LOG, LN |
Natural log |
ln(16) = log(16) = 2.77 |
LOG2 |
Log base 2 |
log2(8) = 3 |
LOG10 |
Log base 10 |
log10(100) = 2 |
CEIL |
Round up |
ceil(6.2) = 7 |
RAND |
Random number |
rnd(1) = .969 |
INT |
Truncate to an integer |
int(6.8) = 6 |
SGN, SIGN |
Sign of expression (-1, 0, or 1) |
sgn(-9) = sign(-9) = -1 |
SQR, SQRT |
Square root |
sqr(64) = sqrt(64) = 8 |
FRAC |
Fraction of float |
fract(5.125)= 0.125 |
AVERAGE |
Average |
average(7, 8, 9, 10, 11) = 9 any number of parameters |
ASC |
Returns ASCII integer of the character |
asc('A') = 65 |
CHR |
Returns character of an ASCII integer |
Chr(65) = 'A' |
STR |
Converts a floating point number into a string of a specified number of digits and right of decimal point |
str(12.3456, 5, 2) = 12.36 |
LEFT |
Copy of the left-most characters from a string |
left('PowerWorld', 5) = 'Power' |
RIGHT |
Copy of the right-most characters from a string |
Right('PowerWorld', 5) = 'World' |
MID |
Copy characters from inside a string starting at a particular character and going a particular number of characters |
Mid('PowerWorld', 3, 5) = 'werWo'
|
TRIM Added in Version 19, build on December 11, 2015 |
Remove leading and trailing spaces from a string |
Trim(' PowerWorld ') = 'PowerWorld' |
LTRIM Added in Version 19, build on December 11, 2015 |
Remove leading spaces from a string |
LTrim(' PowerWorld ') = 'PowerWorld ' |
RTRIM Added in Version 19, build on December 11, 2015 |
Remove trailing spaces from a string |
RTrim(' PowerWorld ') = ' PowerWorld' |
FIND Added in Version 19, build on January 5, 2017 |
Find(Find_Text, Within_Text, [Start_Num]). Returns the integer position of the sub-string Find_Text looking inside the string Within_Text. You may optionally instruct us to start the search at character position Start_Num. If Start_Num is not specified, then we start at position 1. The search is case-sensitive. You may not use wildcard characters * or ?. If Find_Text is not found then function will return 0. |
Find('bc', 'aBcd-xyz-abcd') = 2 Find('bc', 'aBcd-xyz-abcd', 5) = 11
|
SEARCH Added in Version 19, build on January 5, 2017 |
Search(Find_Text, Within_Text, [Start_Num]). Returns the integer position of the sub-string Find_Text looking inside the string Within_Text. You may optionally instruct us to start the search at character position Start_Num. If Start_Num is not specified, then we start at position 1. The search is not case-sensitive. Also the Find_Text may include a ? to indicate any single character of an * to indicate any number of characters. If Find_Text is not found then function will return 0. |
Search('B?d', 'aBcd-xyz-abcd') = 2 Search('B?d', 'aBcd-xyz-abcd', 5) = 0 Search('b?d', 'aBcd-xyz-abcd') = 11 Search('b?d', 'aBcd-xyz-abcd', 5) = 11 Search('B*b', 'aBcd-xyz-abcd', 5) = 2 |
INTEGER, LONG |
Typecast another type as an integer |
|
FLOAT |
Typecast another type as a float |
|
SINGLE |
Typecast another type as a single (4 byte floating point) |
|
DOUBLE |
Typecast another type as a double (8 byte floating point) |
|
STRING |
Typecast another type as a string |
|
TEXT |
Convert floating point number which represents a date into a formatted text string. The integral part of the value is the number of days that have passed since 12/30/1899. The fractional part of the value is fraction of a 24 hour day that has elapsed. See Data and Time Formatting Strings for information on specifying the formatting string. |
Text(42999.760416667, 'mm/dd/yyyy hh:nn:ss AM/PM') = 09/21/2017 6:15:00 PM |
DATETIMEVALUE |
Converts a formatted date string into a floating point number. |
DateTimeValue('9/21/2017 6:15:00 PM') = 42999.760416667 |
DATEVALUE |
Converts a formatted date string into a floating point number. It then truncates the fractional part of the floating point number giving only the integral number of days that have passed since 12/30/1899 |
DateValue('9/21/2017 6:15:00 PM') = 42999.00 |
TIMEVALUE |
Converts a formatted date string into a floating point number. It then removes the integral part of the floating point number giving only the fractional part of a day representing the time |
TimeValue('9/21/2017 6:15:00 PM') = 0.760416667 |
* Functions that evaluate to true or false will return a zero, 0, value if true and a non zero value if false.