| Here are some examples for the six operators with the second highest priority. Note that the modulo operator
'%' requires an integer on the left side. The '//' operator is mainly known to Python programmers,
it is a division with truncation of the result's fractional part. The normal division operator
'/' rounds the result to the closest integer if the requested result data type is an integer.
a = 2
b = 3.
Print (a*b)
6
Print (b*a)
6.0000000000e0
Print (a/b)
1
Print (a//b)
0
Print (b/a)
1.5000000000e0
Print (a%b)
2
Print (b%a)
Error - unsupported operator
The '//' operator is additionally helpful to truncate floating point numbers without rounding:
The shift operators '<<' and '>>' do bitwise binary shifts to the left or right,
they require an integer on the left side. A left shift corresponds to a multiplication with
2, a right shift to a division by 2. That's why they have the same priority as '*' and
'/'.
a = 2
b = 3.000
Print (a<<1)
4
Print (a<<b)
16
Print (a>>1)
1
Print (b>>a)
Error - unsupported operator
|