Logical & Biwise Operators
Logical & Biwise Operators
Bitwise operaors
& - Bitwise AND
| - Bitwise OR
^ - Bitwise XOR
~ - Bitwise NOT
<< - Left Shift
>> - Right Shift
>>> - Right –shifts and shifting in zeros from the left
a=9, b=2
var x = a<<b
a= 9 = 1001
x=100100 =36
left shift 1 bit will multiply the value of a by 2, if 2 bit
then value will be multiple of 4 and so on.
y= a>>1
a= 9 = 1001
y=0100
right shift by 1 bit will divide the value by 2
2 4 and so on
Conditional statements:
A conditional statement takes the following form
1. if (condition)
{
Stmts
}
2. if (condition)
{
Stmts
}
Else
{
Stmts
}
e.g.,