0% found this document useful (0 votes)
22 views3 pages

Logical & Biwise Operators

The document discusses logical operators, bitwise operators, and conditional statements. Logical operators like AND, OR, and NOT are used to test Boolean conditions. Bitwise operators like AND, OR, XOR, and NOT are used to compare bits. Conditional statements like if-else are used to execute code based on conditions being true or false.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views3 pages

Logical & Biwise Operators

The document discusses logical operators, bitwise operators, and conditional statements. Logical operators like AND, OR, and NOT are used to test Boolean conditions. Bitwise operators like AND, OR, XOR, and NOT are used to compare bits. Conditional statements like if-else are used to execute code based on conditions being true or false.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Logical Operators:

Logical operators are used to test condition on Boolean


values, which are either true or false.
Operators are:
&& -AND
|| --OR
! --NOT
e.g,
A>B = T
B>C =T
T && T = T

What happens when operands are not Boolean values?


e.g.,
var test = 0 && true;
// result will be 0

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.,

You might also like