Lecture 4
Lecture 4
Operator Description
~+- Complement, unary plus and minus (method names for the last two are +@ and -
@)
b = 10
c = 15
d=5
e=0
e = (a + b) * c / d #( 30 * 15 ) / 5
e = ((a + b) * c) / d # (30 * 15 ) / 5
e = a + (b * c) / d; # 20 + (150/5)
e= a/d/2
print "a/b/c===", e
Output:
Value of (a + b) * c / d is 90
Value of ((a + b) * c) / d is 90
Value of (a + b) * (c / d) is 90
Value of a + (b * c) / d is 50
a/b/c==== 2
Bitwise operators
1000
1
1001
b = 13 # 13 = 0000 1101
c=0
c = a ^ b; # 49 = 0011 0001
Line 1 - Value of c is 12
Line 2 - Value of c is 61
Line 3 - Value of c is 49
Line 4 - Value of c is -61
Line 5 - Value of c is 240
Line 6 - Value of c is 15
output
true