Predefined Types and Functions

A set of types and functions are provided as described below.

This page discusses:

Types

Supported types are: Boolean, Integer, Double and String.

Boolean
Boolean can take two values: true or false.
Integer
Integer is a 64-bit signed integer number.
Notation:
  • In decimal notation : 1,2,…
  • In decimal notation : 0d125, 0D125
  • In hexadecimal notation : 0xffab1234, 0Xffab1234
  • In binary notation : 0b101100, 0B101100
Double
Double is a 64-bit double precision floating point.
Notation:
  • In floating notation: 1.0, 1., .1, 3.14, …
  • In exponential notation : 1e14
String
String is UNICODE.

Typing Mechanism

You can constrain the type of any variable/IO with types, however constraining a type is not mandatory.

The Behavior Modeler Type inference mechanism determines Variable/IO type from its usage. The computed type can be seen in the tool type of the Variable/IO.

Functions

A set of functions are available. Each function works on specific types or a set of types. Informative error messages appear in case of inconsistencies.

Global Functions

= Equality operator A = B : returns true if the value of A and B are equal
<> Inequality operator A <> B : returns true if the value of A and B are different

Boolean Functions

not not A : returns true if A is false, returns false if A is true
and A and B : returns true if A and B are true, false otherwise
or A or B : returns true if A or B are true, false otherwise
xor A xor B : returns true if A and B have 2 distinct values, false otherwise

Orderable Functions

x < y returns true if x is less than y
x > y returns true if x is greater than y
x <= y returns true if x is less or equal to y
x >= y returns true if x is greater or equal to y
max (x,y) returns x if x is greater than y
min (x,y) returns x id x is less than y

Bitwise Functions

A | B

lor (A, B)

Bitwise or

A & B

land (A, B)

Bitwise and

A ^^ B

lxor (A, B)

Bitwise xor

~A

lnot (A)

Bitwise not

A << N

lsl (A, N)

Left-shift by N bits

A >> N

lsr (A, N)

Right-shift by N bits

Numerical Functions

+ A + B : Addition
- A - B : Substraction
* A * B : Multiplication
/ A / B : Division
** A ** B : Raising to power (exponentiation)
abs abs (A) : Absolute value

Mathematical Functions

x % y

mod(x,y)

Returns the integer modulus of x/y, i.e. x-floor(x/y)*y. Result and

arguments shall have type Real or Integer. If either of the arguments is Real the

result is Real otherwise Integer.

sin (x) sine
cos (x) cosine
tan (x) tangent (x shall not be: ..., -π/2, π/2, 3π/2, ...)
asin (x) inverse sine (-1 ≤ x ≤ 1)
acos (x) inverse cosine (-1 ≤ x ≤ 1)
atan (x) inverse tangent
atan2 (x,y) function calculates the principal value of the arc tangent of y/x, using the signs of the two arguments to determine the quadrant of the result
sinh (x) hyperbolic sine
cosh (x) hyperbolic cosine
tanh (x) hyperbolic tangent
exp (x) exponential, base e
log (x) natural (base e) logarithm (x > 0)
log10 (x) base 10 logarithm (x > 0)
sqrt (x) Returns the square root of v if v>=0. Argument v needs to be an Integer or Real expression.
rand()

Returns a pseudo-random integer in the range between 0 and 32767

rand() % 100 returns a value in the range 0 to 99

String Functions

A ++ B

Concatenate A and B after string conversion.

A and B can be String/Boolean/Integer/Double.

Other Functions

If expr1 then expr2 else expr3 if expr1 is true returns expr2, otherwise returns expr3

Type Conversion Function

BooleanToNumber BooleanToNumber(x) : if true returns 1, otherwise returns 0
NumberToBoolean NumberToBoolean(x) : if zero returns false, otherwise returns true
DoubleToInteger DoubleToInteger(x) : The fractional part is discarded.
IntegerToDouble IntegerToDouble(x) : The integer value is converted into the nearest real value that can be represented into the destination floating-point type.
ToString ToString(x) : Convert Boolean/Integer or Double to Unicode string.

Case Expressions

e1, e2, e3

Record of expressions. Test expression will be compared with record expressions.

Test(v)

case 1,2,3 : ….

n1 -> n2

Between operator. Test expression value has to be between n1 & n2.

Test(v)

case 1 -> 3 : ….

=

Equality operator (Operator is optional).

Test(v)

case 1 : ….

case =2 :…

<>

Inequality operator.

Test(v)

case <>1 : ….

>=

<=

>

<

Comparison operators.

Test(v)

case >1 : ….

case <= -5 :….

Default Values for Simulation

Boolean Integer Double String
False 0 0.0 “”