Literals
A literal is the textual representation of a constant in a formula. The following types of literals can be used:
|
Type |
Example |
|---|---|
|
Decimal integer number |
123 |
|
Decimal floating point number |
1.23 |
|
Hexadecimal number |
0x1FA, 0x1fa |
|
Binary number (e.g. bitmask) |
0b1001010 |
Integers are usually specified as decimal numbers (base 10) using the digits from '0' through '9'. Alternative number systems (bases / radices) can be used by using one of the following prefixes:
|
Prefix |
Base |
Name |
|---|---|---|
|
0b |
2 |
Binary |
|
0x |
16 |
Hexadecimal |
Binary only uses the digits '0' and '1'. Hexadecimal uses digits and letters 'A' through 'F'. The letters in the number are not case sensitive.
Examples:
17 = 0x11 = 0b10001
12 = 0xC = 0xc = 0b1100
Note: Integer literals are currently implicitly treated as floating point numbers.
Floating point numbers use a '.' as decimal separator and optionally allow scientific notation. The general format is:
+/- integer '.' fraction 'e' +/- exponent
Notes:
- +/- is the character '-' or '+' indicating the sign and is optional.
- Integer, fraction and exponent are positive integers.
- Either integer or fraction can be left out.
- The exponent starting at the 'e' is optional.
- Spaces within the number are not allowed.
Examples:
- 2
- -1.5
- 1e3 = 1000
- 3.7e-1 = 0.37
True and false literals are currently not supported. As a workaround the not operation can be used to create Booleans:
|
Boolean |
Workaround |
|---|---|
|
false |
!1 |
|
true |
!0 |
Example:
When delaying a boolean signal by one sample, it is necessary to specify the initial value as a boolean:
State_Register(voltage > 0, !1)