4.7 Left and Right Shift Operator in Java
HTML-код
- Опубликовано: 11 фев 2025
- The left shift operator shifts a bit pattern to the left, and the right shift operator shifts a bit pattern to the right. The bit pattern is given by the left-hand operand, and the number of positions to shift by the right-hand operand. The unsigned right shift operator shifts a zero into the leftmost position.
Check out our courses:
Java Full Stack and Spring AI - go.telusko.com...
Coupon: TELUSKO10 (10% Discount)
DevOps with AWS: From Basics to Mastery : go.telusko.com...
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development : go.telusko.com...
Coupon: TELUSKO20 (20% Discount)
Udemy Courses:
Spring: go.telusko.com...
Java:- go.telusko.com...
Java Spring:- go.telusko.com...
Java For Programmers:- go.telusko.com...
Python : go.telusko.com...
Git : go.telusko.com...
Docker : go.telusko.com...
For More Queries WhatsApp or Call on : +919008963671
website : courses.telusk...
Follow Navin Reddy on Instagram: / navinreddy20
Subscribe to our other channel:
Navin Reddy : / @navinreddy
Telusko Hindi :
/ @teluskohindi
Subscribe to the channel and learn Programming in easy way.
Java Tutorial for Beginners: goo.gl/p10QfB
C Tutorial Playlist : goo.gl/8v92pu
Android Tutorial for Beginners Playlist : goo.gl/MzlIUJ
XML Tutorial : goo.gl/Eo79do
Design Patterns in Java : goo.gl/Kd2MWE
Socket Programming in Java : goo.gl/jlMEbg
Spring MVC Tutorial : goo.gl/9ubbG2
OpenShift Tutorial for Beginners : goo.gl/s58BQH
Spring Framework with Maven : goo.gl/MaEluO
Sql Tutorial for Beginners : goo.gl/x3PrTg
String Handling in Java : goo.gl/zUdPwa
Array in Java : goo.gl/uXTaUy
Java Servlet : goo.gl/R5nHp8
Exception Handling in Java : goo.gl/N4NbAW
Also Just for info : The left-shift by 1 and right-shift by 1 are equivalent to multiplication and division by 2 respectively
Thanks
TYSM!!!
Thanks!
Thank you for the good video. I've been staring at the documentation like a monkey for 30+ minutes before getting it in 3 thanks to you!
thank you..till now i was very confused about this...shift operator..and now ia m able to understable..tq for for ur help ..being in a part of my journey
a>>n is same as a/2^n and a
Thank you for this video. I never understand these terms in programming, but you described these terms in simple language and I can easily understand these terms from now.
you are great sir i have so many basic doubt in java i got demotivated when i see your videos i restored my Confidence
Bhai you are the only one on youtube who knows this correctly thanks it helped me a lot
The best teacher to learn programming 👌❤️
i have been looking for this for so long.. THANKS MUCH FOR THIS!!!
after so many research i finally got the right channel thanks a lot sir
Thanks a lot bro. I have test in 2 days and you saved my life
I doff my cap for you. your explanation is simple easy to understand.
These videos are very helpful.your presentation is good.
easy to understand, thanks for this sir 👍👍
Thanks for the Video. I had trouble to understand this Operation in my Workbook.
Good Work :)
This Operations are faster than the arithmetic division and multiplication Operators.
In time critical processes this can save time.
Great video...I was struggling to find the next power of 2 while implementing segment trees..
i really really like your tutorials.. it's very helpful for me
great simple easy exlplation. Thanks 🙏
So simple thanks !
Iam struggling about this Since 4 days, you just make me clear within 3:14 mins. Thanks Very Much. One suggestion please keep in Mind of the Begginers while doing the lectures because I even don't know how to convert normal number to Binary .
Nice presentation or also in simple way this help full👍👍🌝
Very useful video. I got a clear understanding of this concept now. Thank you!
Hello sir thanks for teach. your way of teach is very good I really fully understand of java fundamental
Subscribed!
Thank you soooo muchh sir you explained it is soo simple language tysm !!!
Thanks a lot Bro ☺️☺️☺️..now i understand this method.
Thank you so much sir ....big of thumb..👍🏻
Thanks you.. The video was very good...
great guru 🫡
Vary vary thanks 😃
Thank you a lot my dear.
Keep going 👍🏻
Easily understood thankx
Right shift filled with zero ?
Wow nice expanation I got cleared with this doubt
It would be great if you could include unisgned and signed shift operators
i like this video bcoz this is very short and easy
really helpful thanks
So shortcut is in left shift add specified number of zeros at the end, in right shift remove the specified number of zeros and ones at the end?
Thanks a lot brother
Thanks a lot, Sir
where do we use left shift and right shift operators?
Bit manipulation
A good example to get started is that if you are given a number,then find the next greater number which can be written in the power of 2.
Example-If you are given 5, then you should return 8(2^3).
The above mentioned program is also useful when trying to implement advanced data structures like Segment trees.That's what got me here :P
very helpful thanks
Great Janab Allah bless you!
Thank you sir
easy and helpful
Thanks man😺
Best among all
which software is this ?
thank you
very helpful
tq sir
Thank you soooooooooo much
Thank you :)
So Right shift ->it loose last 2digit
Left shift ->it will add 2 zero in the last
Thanks a lot.
Thank you!
The best ever
Thanks
i have doubts..for assessment
i applied infosys springboard intern 5.0
Hii....Is assessment compulsory for selection procress?
Thank you!!
why we use shift operator, what is advantage of using shift operator
Check If This Helps.
stackoverflow.com/questions/7454619/why-do-we-need-to-use-shift-operators-in-java
Difference between Right shift and Unsigned right shift in Java ( >> and >>> )
?
thanks bro
int num = 5;
// Left shift :
int b1 = num >> 1; // 2 ^ 1 = 2 , 5 /2 = 2
int b2 = num >> 2; // 2 ^ 2 = 4 , 5 / 4 = 1
int b3 = num >> 3; // 2 ^ 3 = 8 . 5 / 8 = 0
System.out.println(b1 + " " + b2 + " " + b3); // 2 1 0
// Right shift :
int c1 = num
Whats realtime application for shift operators?
love uuuuuuuuuuuuuu bhai
Thank yu
what is the use of the left right shift operator?
Pls help
Int a=64
Byte b=(byte) (a
If we left shift by 2 bits it's value become from 64 to 256 and
And you are trying to get this output in the byte type. The byte can only store value from -128 to 127.
So the output has one error
Can you please explain unsigned right shift as well ?
i love you
sir what is difference between >> and >>> ?
when i will use it?
i am getting different output
2>>5 gives 0
-2>>>5 gives 134217727
-2>>5 gives -1
and
2>>>5 give 0
?
why ?
>> is signed right shift, >>> is unsigned right shift...i.e. >>> fills up 2's complement form of the number from right side
thanks, finally i found a good explanation
Sir differen between >> $ >>>.
Please tell...
Sir what if the variable type is float in this example
Why should we use this shift operator in java ? Tell me real life example for this ..
it is use full
How are you remember this all decimal numbers binary form ?
It is 8421 code or formula
1o1o this os binary of 10 decimal
can you explain this ">>>"
3 bits right shift
I find it baffling that every time I search for something about computer programming, I always end-up on a tutorial by someone with an Indian accent.
One day Indians will rule the world 🌎
What's the difference between >> and >>>
>> (right shift)
Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand.
Ex: i=8; //1000 in binary
i >> 2; // gives 10 in binary
>>> (zero fill right shift)
Shift right zero fill operator. The left operands value is moved right by the number of bits specified by the right operand and shifted values are filled up with zeros.
Ex: i =8; //1000 in binary
i >>> 2; // this gives 0010 in binary
how to convert numbers to boolean
Great
wow i dont know this exists!
Sir...But why left shift will add bits to it and right shift will loose 2 bits?? Why the left shift not loosing 2 bits from left side?
Because you shift from right to left
make simple program we can understand just debit credit addition multiplication making of atm matrix u can make that is hard program u have made but saving that video
Coz We perform any operation on binary from left..... Moreover no. Has to be shift left..... So wont u apply force from right😉
100 - 1100100
100 >> 5
Answer is 4 How?
how is 1000 8?
👍👍👍
How to covert a number into binary number any one help me plzz
👍
Teluskunnanu sir
ty ty helpullll
8 ko 1000 me kaise convert kiya
Interesting, but could anyone tell me when and where are those useful? I've been programming for some time and never had to use this operators
Because we don't think about memory level optimization.
For ex. We can double & half a number just by shifting one bit, whereas we will use traditional approach by multiplying or adding
@@dhritiayusj2710 yeah it applies on games and high specs softwares
oh left shiftt will add 0 and right will remove.come on bhai agar sahi se nhi aata to pahle knowledge lo phir video banana.theek hai
gd
Bcs306a 😂
sounds like a guy from a hotline
nvtheless amazing video!