Shift Operators in Java || Lesson 10 || Java Programming || Learning Monkey ||

preview_player
Показать описание
Shift Operators in Java
In this class, We discuss Shift Operators in Java.
The reader should have prior knowledge of bitwise operators. Click here.
Shift Operators:
Left Shift
Right Shift Holding sign
Right Shift Unsigned
Example:
int a= 10, b;
b= altlt1;
Here 1 means shift bits left side one time.
b=altlt2 means shift bits left side 2 times.
a=10, the binary value of 10 is 001010.
In our example, we are showing 6 bits. But in the system, 32 bits are assigned.
Left shift place zero in the least significant bit position.
The least significant bit is moved to the 2nd position.
The actual bit in the second position is moved to 3rd position.
Similarly, each bit is moved to one position left.
After leaving Shift one time, the output is saved in the variable b.
Important: Initial a = 10. After the left Shift, the value is 20.
one left Shift will increase the value multiplied by 2.
agtgt2 will have a value of 40.
Each left shift operation will double the value.
Right Shift:
The right Shift starts from the most significant bit.
a=10, b;
b = agtgt1 will right shift one bit.
The most significant bit will be copied to maintain the sign.
The most significant bit is moved to the next position, and so on.
The right shift operation will make the value divisible by 2.
a=10;
b = agtgt1 will have a value of 5.
b= agtgt2 will have a value of 2.
right, Shift two times.
First time 10/2 = 5
The second time 5/2 = 2.5, but the Shift maintains the floor value.
The floor value of 2.5 is 2
Similarly, a floor value of -2.5 is -3.
The division maintains the floor value all the time.
Right Shift
This right shift operation will place zero in the most significant bit position.
After that, Shift the most significant bit to one bit right, and so on.
Here we are not maintaining the sign of the number.
Link for playlists:

Рекомендации по теме
Комментарии
Автор

sir your web site is really good
how to to build a web site like the one you have?
please make a playlist on it
i am 1 st year in cse though!

mtbmtbmtbcycle
Автор

sir can you make a video on this topic really quick i have java exam in 2 days please sir

Explain the following operations with examples. (i)<< (ii)>> (iii)>>>

certifiedbeast
Автор

can we do a left shift to negative numbers ? if yes then like how right shift(>>) maintains sign, the same should be applicable to left shit, is that right ? also it is wrong method to teach right shift(>>) because while doing right shift we need to put zero as the right side's first element like how we put zero in left side's first element of left shift. but you mentioned that first bit of right shift's first element should always be what we have as first element. please correct it.

navaskhaniv-b
Автор

Brother can I skip java and go with python? I have competed c & c++

Vishnubhandarge