Appendices, Expressions, Conditions – CIRCUTOR PowerStudio Series User Manual

Page 103: Expressions and conditions

Advertising
background image

PowerStudio

User Manual 103

11.- APPENDICES

11.1.- EXPRESSIONS AND CONDITIONS


Many parts of the program allow the inclusion of terms or conditions. To enter these there is a

standard text control available accompanied by a help button that will guide you through editing them.

Real numbers can be used in an expression or condition (in accordance with the IEEE 754-

1985 standard, where among other aspects, it stipulates that the decimal separator is the “.”) symbol,
parentheses (“(” and “)”), addition operators (“+”), subtraction operators (“-“), multiplication operators
(“*”), division operators (“/”) and exponential operators (“^”). Thus, some valid examples would be:

2*(4.56^2)
1-(2.12-4)/2


The following mathematical functions can also be used:


sqrt(exp)

: Square root of the expression "exp

log(exp)

: Natural logarithm of the expression "exp

exp(exp)

: Number “e” to the power of expression “exp

sin(exp)

: Sine of the expression "exp" (in radians)

cos(exp)

: Cosine of the expression "exp" (in radians)

tan(exp)

: Tangent of the expression "exp" (in radians)

asin(exp)

: Arcsine of the expression "exp"

acos(exp)

: Arccosine of the expression "exp" (in radians)

atan(exp)

: Arctangent of the expression "exp"

atan2(exp1, exp2)

: Extended arctangent of the expression “exp1/exp2

log10(exp)

: Base 10 logarithm of the expression "exp

round(exp)

: Rounding off to whole number nearest to the expression "exp"

trunc(exp)

: Truncation to the whole number of the expression "exp"

pi() : Returns the number PI (3.1415927…).

e() : Returns the number E (2.7182818…).
mod(exp1, exp2):

Return the modulus "exp2" of expression "exp1

max(exp1, exp2):

Returns the maximum of the two expressions

min(exp1, exp2):

Return the minimum of the two expressions

abs(exp):

Returns the absolute value of the expression "exp"

rand():

Returns a real random value between 0.0 and 1.0

if(cond, exp1, exp2):

Evaluates the condition “cond”. If the condition is true it returns

the expression "exp1" if false it returns the expression "exp2

bit(exp1, exp2):

Returns the value of the positioning bit "exp2" for the number "exp1".

setbit(exp1, exp2, exp3):

Returns the value obtained by placing the positioning bit

"exp2" the value "exp3" to the number "exp1".

normalize(exp1, exp2):

Returns “exp1” if “exp1” can be evaluated, otherwise it returns

exp2”.

We should remember some details about these functions. The square root function will return

an error if the expression is negative. The logarithmic functions ( "log" and "log10")will return and error
if the expression is less than or equal to zero. The Arctangent function ( “atan”) assesses a range that
goes from -

π/2 to π/2 and returns zero if the expression is zero. The extended Arctangent function (

"atan2") assesses a range that goes from –

π to π and returns zero if both expressions are zero. The

Arcsine functions ( "asin"), Arccosine ( "acos"), Arctangent ( "atan") and extended Arctangent (
"atan2") return the result in radiants. The functions that return the number pi ( "pi") and e ( "e") have no
parameters, so they can be used with or without parentheses. The functions are not case sensitive.
Examples of valid formulas are:

2*pi()-sqrt(10)

round(exp(2)+atan2(1.2)-e*pi)


Advertising