Это видео недоступно.
Сожалеем об этом.
Shift Operators in Java || Lesson 10 || Java Programming || Learning Monkey ||
HTML-код
- Опубликовано: 12 авг 2024
- 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.
System.out.println(b); will display 20.
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:
/ @learningmonkey
Link for our website: learningmonkey.in
Follow us on Facebook @ / learningmonkey
Follow us on Instagram @ / learningmonkey1
Follow us on Twitter @ / _learningmonkey
Mail us @ learningmonkey01@gmail.com
Super bro well explained ❤😊
Have a great learning in CSE
good sir ji
Good explanation. Thank u❤
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)> (iii)>>>
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!
Yes we are starting full stack web development course from July.
Have a great learning
@@LearningMonkey Thank you Sir
🙂
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.
Right shift follows arithmetic right shift.
Our explanation is correct.
Please once execute the code .
Left shif is also correct
Brother can I skip java and go with python? I have competed c & c++
Yes go with python.