Successfully reported this slideshow.

# operators.ppt

Upcoming SlideShare
3306617
×

1 of 16 Ad

# operators.ppt

Argently if it is needed

Argently if it is needed

## More Related Content

### operators.ppt

1. 1. Operator Kinds of Operator Precedence of Operator Type Casting
2. 2. Operator  Decide the semantics of expression  Meaning of operator given in language system
3. 3. Kinds of Operator Arithmetic Op. : + - * / % Relational Op. : > >= < <= == != Logical Op. : && || ! Inc/Dec Op. : ++ -- Bit Op. : & | ^ ~ << >> >>> Operators of Java Conditional Op. : ?: Assign Op. : = += -= *= /= %= &= ^= |= >>= <<= >>>= Casting Op. : (Data Type) Array Op. : [] Method Op. : () . instanceof Op. : instanceof
4. 4. Arithmetic Operator  Operator for arithmetic operation  Single term operator : +, -  Binary term operator : +, -, *, /, %  [ArithmeticOperators.java] x = -5 ; x = -(-5) ; x = -(3-5) ;
5. 5. Arithmetic Operator  Real type operation  Floating point discription and operation: IEEE754 Standard  underflow, overflow  Infinitive arithmetic  java.lang.Float, java.lang.Double, POSITIVE_INFINITY, NEGATIVE_INFINITY constant  NaN(Not a Number)
6. 6. Arithmetic Operator  Add, Substract  Multiply, Divide x y x+y x-y +I.F +I.F +I.F NaN +I.F - I.F NaN +I.F - I.F +I.F NaN - I.F - I.F - I.F - I.F NaN NaN +I.F NaN NaN x y x/y x%y Finite 0.0  I.F NaN Finite I.F 0.0  0.0 0.0 NaN NaN I.F Finite  I.F NaN I.F I.F NaN NaN  [InfinityArithmetic.java]
7. 7. Relational Operator  Compare two value  Result : true or false  Expression include relational operator  for, while, ...  Operator  , , , , ,   precedence   [RelationalOperators.java] a > b + c ===> a > (b + c) b == x < y ===> b == (x < y)
8. 8. Conditional Operator  Conditional Logical Relationship of two operands  Operator  ! , && , ||  [LogicalOperators.java] a < b && b < c 1 2 3
9. 9. Increment & Decrement Operator  Operator  ++, --  Prefix operator  Postfix operator  Cannot use at expression, only at variable  Cannot apply at real type  [IncDecOperators.java] n = 1; x = ++n; // x=2, n=2 n = 1; x = n++; // x=1, n=2 (a + b)++ // error
10. 10. Bitwise Operator  Operator  &, |, <<, >>, >>>, ^, ~  Operand should be integer type  Precedence Operator Precedence ~ << >> >>> & ^ | (H) (L)
11. 11. Bitwise Operator  Bitwise AND  10012 & 00112 = 00012  To extract the special area in variable by masking that area  Bit OR  10012 | 00112 = 10112  Exclusive AND  10012 ^ 00112 = 10102  1’s Complement  ~ 000010102 = 111101012  [BitOperators.java]
12. 12. Bitwise Operator  Bitwise Shift Operator  Shift lefe(<<)  Shift right(>>)  Unsigned shift right(>>>)  Give this operator because Java does not support unsigned integer.  [ShiftOperators.java] x << y = x * 2y x >> y = x / 2y
13. 13. The Conditional Operator  Operator  Expr1 ? Expr2 : Expr3 (3 Terms Operator)  [ConditionalOperator.java]  [PrintTenItem.java] m = a > b ? (c > a ? c : a) : (c > b ? c : b) ; max = x > y ? x : y ; if (x > y) max = x; else max = y;
14. 14. Assignment Operators  Operator  Arithmetic operator : + - * / %  Bitwise operator : & | ^ << >> >>>  [AssignmentOperators.java] Expr 1 = Expr 1 op Expr2 Expr1 op= Expr 2 x = x * y + 1; x *= y + 1; x = x * (y+1) sum = sum + i ; sum += i ;
15. 15. Cast Operator  Data Type Casting Operator  Cast operator : ( , )  [CastOperator.java] (Data Type) 식 (int) 3.75 ===> 3 (float) 3 ===> 3.0 (float) (1 / 2) ===> 0.0 (float)1/2 ===> 0.5
16. 16. Operator Precedence Operator Association Precedence () [] . ! ~ ++ -- + - (Data Type) * / % + - << >> >>> < <= > >= instance == != & ^ | && || ? : = += -= *= /= %= &= ^= |= <<= >>= >>>= Left Assoc. (High) Left Assoc. Left Assoc. Left Assoc. Left Assoc. Left Assoc. Left Assoc. Left Assoc. Left Assoc. Left Assoc. Left Assoc. Left Assoc. Left Assoc. Left Assoc. (Low)