Download presentation
Presentation is loading. Please wait.
Published byPia Leppänen Modified over 6 years ago
1
4TC00 Model-based systems engineering 2.2 Types and values
Bert van Beek (dr.ir. D.A. van Beek) Gem-Z 0.120
2
Answers of first guided self study are online
This is the normal exercises website. Refresh your browser if you do not see a new 4TC00 ANSWERS section at the end of the table of contents. s.html Specific link to go directly to the answers on the exercises website.
3
Examples of type, values and expressions
disc int x = 1; disc int y = 2 * x; int is a type 1 is a value (of type int) 2 * x is an expression, but x and 1 are also expressions
4
CIF definition of Type
5
Types and values Type of a variable is the set of all allowed values of the variable. Type also defines the allowed operations on variables and expressions of the type. Type Allowed values Default initial value bool true, false false int[1..3] 1, 2, 3 1 int integer values real 1.35, -25e5, etc string “true”, “hello world”, etc “”
6
Expressions A simple expression is a:
literal value variable function call Expressions can be composed of other expressions by means of operators Expressions can be evaluated, resulting in a value
7
Integers and operators
// 9 // 9 // 13 // 5 9 * // 36 9 / // 2.25 (result is a real number, not an integer number) 9 div // 2 (9 / 4 = 2.25, so 4 fits at two whole times in 9) 9 mod // 1 (the remainder of 9 div 4) pow(2, 4) // 16 (2 to the power of 4, or 2 * 2 * 2 * 2) abs(-9) // 9 (absolute value) min(9, 4) // 4 (minimum value) max(9, 4) // 9 (maximum value)
8
Reals and operators +1.23 // 1.23 --1.2 // 1.2 1.5 + 0.5 // 2.0
// 1.23 // 1.2 // 2.0 // 1.0 1.5 * // 0.75 1.5 / // 3.0 pow(3.5, 2.0) // (3.5 to the power of 2, or 3.5 * 3.5) abs(-1.5) // (absolute value) min(1.5, 0.5) // (minimum value) max(1.5, 0.5) // (maximum value) sqrt(16.0) // (square root) cbrt(16.0) // (cube root) sin(1.0) // (sine) cos(1.0) // (cosine) tan(1.0) // (tangent) log(100.0) // (logarithm to base 10) ln(100.0) // (natural logarithm)
9
Operators on reals and integers
x < y // less than x <= y // less than or equal to x = y // equal to x != y // not equal to x >= y // larger than or equal to x > y // larger than round(1.6) // 2 (round real to closest integer, half up) ceil(0.7) // 1 (round real up to integer) floor(0.7) // 0 (round real down to integer)
10
Boolean operators not x // inverse
x and y // conjunction (both x and y must hold) x or y // disjunction (either x, y, or both must hold) x => y // implication (if x holds, y must hold)
11
"hello" + " " + "world" = "hello world"
String concatenation "hello" + " " + "world" = "hello world"
12
Enumerations enum TrafficColor = RED, ORANGE, GREEN; // enum declaration automaton A: event change_color; disc TrafficColor light = RED; location: initial; edge change_color when light = RED do light := GREEN; end
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.