Primitives
component Dummy {
int myIntField = 0;
long myLongField = 0;
float myFloatField = 0.0f;
double myDoubleField = 0.0;
boolean myBoolField = false;
char myCharField = 'a';
}
MontiArc provides the following primitive data types:
Integer numbers
intwith values between-2³¹and2³¹ - 1longwith values between-2⁶³and2⁶³ - 1
Normally, integer literals are of the type int.
However, it is also possible to create literals that are explicitly of the type long by adding an l or L as a suffix: 42l or 42L. (L is the recommended suffix, as l is similar to 1).
Values of type int can be assigned to entities of the long, double, float, and char types.
Floating-point numbers
floatis a single-precision 32-bit IEEE 754 floating pointdoubleis a double-precision 64-bit IEEE 754 floating point
The behavior of floating-point numbers (e.g., rounding after math operations) follows the behavior of Java's floating-point numbers.
Normally, floating-point literals are of the type double.
However, it is also possible to create literals of the type float by adding f or F as a suffix: 2.0f or 2.0F.
Values of the type float can be assigned to entities of the double type.
Boolean values
boolean data can have two different values: true and false
Character values
char is a 16-bit Unicode character.
It is possible to define a character value by its Unicode code point. To this end, the hexadecimal Unicode code follows the Unicode escape \u: char foo = '\u0F23'.
Moreover, MontiArc features the same escape codes as Java for commonly used control characters, such as \n for new line.
Character values can be assigned to entities of the int, long, double, and float types.
Void
While the void type is not usable as a type of values, it is recognized as the return type of methods that do not return anything:
automaton {
// ...
A -> B / { executeVoidMethod(); }
}