WiFi MAC Transmitter
WiFi MAC Transmitter
Classifications
Arithmetic operators Relational operators Logical operators Assignment operators Increment and decrement operators Conditional operators Bitwise operators Special operators
Kinds of Operator
Arithmetic Op. : + * / % Relational Op. : > >= < <= == != Logical Op. : && || ! Inc/Dec Op. : ++ -Bit Op. : & | ^ ~ << >> >>> Conditional Op. : ?: Assign Op. : = += -= *= /= %= &= ^= |= >>= <<= >>>= Casting Op. : (Data Type) Array Op. : [ ] Method Op. : () . instanceof Op. : instanceof
Operators
Arithmetic Operators
Operator for arithmetic operation
operators : +, -, *, /, %
a-b a*b a+b a%b -a*b a/b
7/4 9.0 9/4 4/7 =1; 4%7 = 4; / 2= 4.5; 7%4 = 3; =2; 9/2.0 = 4.5; = 0; 9.0/2.0 = 4.5;
Integer arithmetic
Note: In modulo division, the sign of the result is always the sign of the first operand (dividend).
6/3 = 2 -6/3 = -2 6/-3 = -2 -6/-3 = 2 7%3 = 1 -7%3 = -1 7%-3 = 1 -7%-3 = -1
Order of evaluation can be changed by introducing parentheses Ex: 1.a = 9, b = 12, c = 3 x = a b/(3 + c)*(2 1) For nested parentheses, inner most parentheses will be first evaluated. Ex: x = 9 ((12/3) + 3*2) 1
Relational Operators
Compare two value. Result : true (1)or false (0). Zero is false, non zero integer is true.
Relational Operators
7>4 = 1 7>4 Examples: = 1 7>9 = 0; 7>9 = 0; 7<9 = 1; 7<9 = 1; 7 == 7 = 1; 7 == 7 = 1; 7 == 9 =0; 7 == 9 =0; 7 !=7 =0; 7 !=7 =0; 10<7+5 10<7+5 a+b == c+d a+b == c+d
Relational Operators
true true true if a+b is equal to c+d true if a+b is equal to c+d
7>=4 = 1; 7>=7 = 1; 7>=4 = 1; 7>=7 = 1; 9<=7 = 0; if at least one condition is true ,, 9<=7 = 0; if at least one condition is true result is true. result is true.
Logical Operators
Operators && ! || Logical AND Logical NOT Logical OR
Assignment Operators
Expr1 = Expr1 op Expr2 Expr1 = Expr1 op Expr2 Expr1 op= Expr 2 Expr1 op= Expr 2
Ex:
x = x * (y+1) x = x * (y+1)
Postfix operator (assignment and then // x=1, n=2 // x=1, n=2 evaluation)
(a + b)++ // error (a + b)++ // error
m = aa> bb??(c > aa??cc::a) ::(c > bb??cc::b) ;; m= > (c > a) (c > b)
if (a > b) if (a > b) then if(c>a) then if(c>a) m = c; m = c; else m=a; else m=a;
if (a > b) if (a > b) then if(c>b) then if(c>b) m = c; m = c; else m=b; else m=b;
Bitwise Operators
Operand should be integer type
Bitwise Operators
Precedence
Operator Precedence
(H)
(L)
Bitwise Operators
Bitwise AND
10012 & 00112 = 00012 To extract the special area in variable by masking that area
Bit OR
10012 | 00112 = 10112
Exclusive OR
10012 ^ 00112 = 10102
1s Complement
~ 000010102 = 111101012
Bitwise Operators
Bitwise Shift Operator
Shift left(<<)
x << y = x **2yy x << y = x 2
Shift right(>>)
x >> y = x //2yy x >> y = x 2
Special operators
1. The Comma operator: used to link the related expressions together. Evaluated left to right has lowest precedence, parentheses are necessary. Ex: value = (x=10,y=5,x+y);
Special operators
2. The sizeof operator: It returns the number of bytes the operand occupies. the operand can be a variable, constant or a data type qualifier. Ex: m = sizeof(sum); n = sizeof(long int); k = sizeof(235L);
Operator Precedence
Operator Association
Left Assoc. () [] . (High) ! ~ ++ -- + - (Data Type) Left Assoc. * / % Left Assoc. + Left Assoc. << >> >>> Left Assoc. < <= > >= instance Left Assoc. Left Assoc. == != Left Assoc. & Left Assoc. ^ Left Assoc. | Left Assoc. && Left Assoc. || Left Assoc. ?: Left Assoc. = += -= *= /= %= &= ^= |= <<= >>= >>>= (Low)
Precedenc
Operator Precedence
a = x + y - z ; // Left Association b = -x ; // Right Association c = -x++ ; d = -++x ; e = -x + z ;
Operator Precedence
Example: 3 + 4*5 6/2 + 7*8 3 + 20 - 6/2 + 7*8 3 + 20 - 3 + 7*8 3 + 20 - 3 + 56 23 -3 +56 20 + 56 76
Operators
Determine the hierarchy of operations and evaluate the following expression: i=2*3/4+4/4+8-2+ 5/8
Operators
i=6/4+4/4+8-2+5/8 operation: * i=1+4/4+8-2+5/8 operation: / L-R i = 1 + 1+ 8 - 2 + 5 / 8 operation: / L-R i=1+1+8-2+0 operation: / L-R i=2+8-2+0 operation: +