Instructions

179 C-Control Pro IDE
© 2013 Conrad Electronic
4.2.5.1
Arithmetic Operators
All arithmetic operators with the exception of Modulo are defined for Integer and Floating Point data
types. Modulo is restricted to data type Integer only.
It must be observed that in an expression the figure 7 will have an Integer data type assigned to
it. If a figure of data type float should be explicitly created then a decimal point has to be added: 7.0
Operator
Description
Example
Result
+
Addition
2+1
3.2 + 4
3
7.2
-
Subtraction
2 - 3
22 - 1.1e1
-1
11
*
Multiplication
5 * 4
20
/
Division
7 / 2
7.0 / 2
3
3.5
%
Modulo
15 % 4
17 % 2
3
1
-
Negative Sign
-(2+2)
-4
4.2.5.2 Bit Operators
Bit operators are only allowed for Integer data types
Operator
Description
Example
Result
&
And
0x0f & 3
0xf0 & 0x0f
3
0
|
Or
1 | 3
0xf0 | 0x0f
3
0xff
^
exclusive Or
0xff ^ 0x0f
0xf0 ^ 0x0f
0xf0
0xff
~
Bit inversion
~0xff
~0xf0
0
0x0f
4.2.5.3 Bit-Shift Operators
Bit-Shift operators are only allowed for Integer data types. With a Bit-Shift operation a 0 will always
be moved into one end.
Operator
Description
Example
Result
<<
shift to left
1 << 2
3 << 3
4
24
>>
shift to right
0xff >> 6
3