BitWise Right Shift Operator
Bitwise Right Shift Operator which is denoted by >> ,shifts all bits in a value to the right of specified number of times.
Syntax:-
value >> number
where value is,whose bits are to be shifted by number of times specified by number.
for example:- Shifting 32 to right by two positions
24 >> 2 equal to 6
27 >> 2 equal to 6
Explanation:-
24 in binary form is given by 00011000 which after shifting twice returns 00000110 which is equal to 6.Similarly 27 after shifting twice also result in 6 due to loss of lower order bits.
NOTE:-Each time we shift a value we are dividing the value by 2 and leave any remainder.
In this signed right shift operation the sign of value remains preserved.When we are shifting right the higher order bit is shifted and it is replaced by the previous content of highest order bit.This is called as sign extension and it preserves the sign of the value
For Example:-
- 8 >>.1 = - 4 as following happens
11111000 >> 1
11111100 and it is equal to - 4
IMPORTANT:-Value of -1 remains same whether it is shifted or not because its binary value is 11111111.If you will shift this value you will get the same result.
Go to:-
Home
Assignment Operators
Arithmetic Operators
Logical operators
Relational Operators
Conditional Operators
Bitwise Operator Intro
Bitwise Logical operator
Bitwise Left shift Operator
Sponsored Links :-
Get Your SCJP preparation Kit free!!!!!!!
Get Your SCWCD preparation Kit free!!!
Are you Intelligent check here


















0 comments:
Post a Comment
Post a Comment