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

Комментарии • 128

  • @sushant1431
    @sushant1431 6 лет назад +106

    Also Just for info : The left-shift by 1 and right-shift by 1 are equivalent to multiplication and division by 2 respectively

  • @theresapan6128
    @theresapan6128 3 года назад +1

    Thanks!

  • @kristiyangerasimov6708
    @kristiyangerasimov6708 3 года назад +6

    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!

  • @bondevolution4335
    @bondevolution4335 4 месяца назад

    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

  • @Harshit156YT
    @Harshit156YT 2 года назад +1

    a>>n is same as a/2^n and a

  • @tech100sec
    @tech100sec 7 лет назад +2

    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.

  • @tanveersayyed561
    @tanveersayyed561 3 года назад

    you are great sir i have so many basic doubt in java i got demotivated when i see your videos i restored my Confidence

  • @akshitrathi9118
    @akshitrathi9118 5 лет назад

    Bhai you are the only one on youtube who knows this correctly thanks it helped me a lot

  • @solomonvandy6249
    @solomonvandy6249 3 года назад +1

    The best teacher to learn programming 👌❤️

  • @palakgambhir8112
    @palakgambhir8112 4 года назад +1

    i have been looking for this for so long.. THANKS MUCH FOR THIS!!!

  • @SachinAnalyzes
    @SachinAnalyzes 7 лет назад

    after so many research i finally got the right channel thanks a lot sir

  • @tsvetelinpeshev9433
    @tsvetelinpeshev9433 3 года назад

    Thanks a lot bro. I have test in 2 days and you saved my life

  • @TemidayoOmoseebi-ug1mi
    @TemidayoOmoseebi-ug1mi Год назад

    I doff my cap for you. your explanation is simple easy to understand.

  • @imily7569
    @imily7569 4 года назад +1

    These videos are very helpful.your presentation is good.

  • @SmartProgramming
    @SmartProgramming 7 лет назад +2

    easy to understand, thanks for this sir 👍👍

  • @Yuka_1990
    @Yuka_1990 5 лет назад +7

    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.

  • @TheGamerGuy201
    @TheGamerGuy201 7 лет назад +2

    Great video...I was struggling to find the next power of 2 while implementing segment trees..

  • @lionciomorcilla4743
    @lionciomorcilla4743 7 лет назад +3

    i really really like your tutorials.. it's very helpful for me

  • @arunabhachatterjee9979
    @arunabhachatterjee9979 7 месяцев назад

    great simple easy exlplation. Thanks 🙏

  • @fightermad
    @fightermad 3 месяца назад

    So simple thanks !

  • @ssk5433
    @ssk5433 4 года назад

    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 .

  • @offline5756
    @offline5756 3 года назад

    Nice presentation or also in simple way this help full👍👍🌝

  • @ArjunKalidas
    @ArjunKalidas 5 лет назад

    Very useful video. I got a clear understanding of this concept now. Thank you!

  • @taradatt8929
    @taradatt8929 7 лет назад

    Hello sir thanks for teach. your way of teach is very good I really fully understand of java fundamental

  • @14dayztimeap8
    @14dayztimeap8 Год назад +1

    Subscribed!

  • @gyuwins
    @gyuwins 3 года назад

    Thank you soooo muchh sir you explained it is soo simple language tysm !!!

  • @prashanth783
    @prashanth783 5 лет назад

    Thanks a lot Bro ☺️☺️☺️..now i understand this method.

  • @KashifKhan-vc5jb
    @KashifKhan-vc5jb 3 года назад

    Thank you so much sir ....big of thumb..👍🏻

  • @ArnabKrDas
    @ArnabKrDas 3 года назад

    Thanks you.. The video was very good...

  • @dineshprajapat2264
    @dineshprajapat2264 Месяц назад

    great guru 🫡

  • @Experience_is_Life
    @Experience_is_Life 4 года назад +1

    Vary vary thanks 😃

  • @abderahmaneyous8568
    @abderahmaneyous8568 5 лет назад +1

    Thank you a lot my dear.

  • @Kawaterwhukam
    @Kawaterwhukam 11 месяцев назад

    Keep going 👍🏻

  • @havemercy2742
    @havemercy2742 6 лет назад +1

    Easily understood thankx

  • @sharukhbilal9001
    @sharukhbilal9001 7 лет назад

    Wow nice expanation I got cleared with this doubt

  • @abrehamish
    @abrehamish 4 года назад +1

    It would be great if you could include unisgned and signed shift operators

  • @shakeebarsalan970
    @shakeebarsalan970 8 лет назад

    i like this video bcoz this is very short and easy

  • @shivanineharkar2571
    @shivanineharkar2571 3 года назад

    really helpful thanks

  • @ArkoSarkar1
    @ArkoSarkar1 6 лет назад +2

    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?

  • @aromaljayachandran4300
    @aromaljayachandran4300 3 года назад

    Thanks a lot brother

  • @architsharma6068
    @architsharma6068 8 лет назад +1

    Thanks a lot, Sir

  • @shakiraafshan6544
    @shakiraafshan6544 7 лет назад +14

    where do we use left shift and right shift operators?

    • @TheGamerGuy201
      @TheGamerGuy201 7 лет назад +19

      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

  • @slizora5704
    @slizora5704 2 года назад

    very helpful thanks

  • @maalikcodes9854
    @maalikcodes9854 3 года назад

    Great Janab Allah bless you!

  • @santanukumarpandapanda7588
    @santanukumarpandapanda7588 Год назад

    Thank you sir

  • @uzair004
    @uzair004 5 лет назад

    easy and helpful

  • @tusharhalder4480
    @tusharhalder4480 4 года назад

    Thanks man😺

  • @shaileshchandra1878
    @shaileshchandra1878 7 лет назад

    Best among all

  • @shwetanakhate1862
    @shwetanakhate1862 Год назад +1

    which software is this ?

  • @sorbunsong6934
    @sorbunsong6934 3 года назад

    thank you

  • @shuvshaw9594
    @shuvshaw9594 5 лет назад

    very helpful

  • @saravana8016
    @saravana8016 8 лет назад

    tq sir

  • @tumpadas2035
    @tumpadas2035 6 лет назад

    Thank you soooooooooo much

  • @akankshasoni5758
    @akankshasoni5758 4 года назад

    Thank you :)

  • @RajkamalKamal-bh9jq
    @RajkamalKamal-bh9jq 2 года назад

    So Right shift ->it loose last 2digit
    Left shift ->it will add 2 zero in the last

  • @coding_ss632
    @coding_ss632 6 лет назад

    Thanks a lot.

  • @javierpizarro7806
    @javierpizarro7806 8 лет назад

    Thank you!

  • @ajiboladaniel9386
    @ajiboladaniel9386 Год назад

    The best ever

  • @chelseyerwin376
    @chelseyerwin376 Год назад

    Thanks

  • @MeghanaManukonda
    @MeghanaManukonda 6 месяцев назад

    i have doubts..for assessment
    i applied infosys springboard intern 5.0

  • @MeghanaManukonda
    @MeghanaManukonda 6 месяцев назад

    Hii....Is assessment compulsory for selection procress?

  • @readbearttu3606
    @readbearttu3606 6 лет назад

    Thank you!!

  • @weslinpaul2383
    @weslinpaul2383 8 лет назад +2

    why we use shift operator, what is advantage of using shift operator

    • @screwedidiot937
      @screwedidiot937 8 лет назад

      Check If This Helps.
      stackoverflow.com/questions/7454619/why-do-we-need-to-use-shift-operators-in-java

  • @umessr8456
    @umessr8456 4 года назад

    Difference between Right shift and Unsigned right shift in Java ( >> and >>> )
    ?

  • @viorelpaluta3815
    @viorelpaluta3815 3 года назад

    thanks bro

  • @nishanksoni7120
    @nishanksoni7120 4 года назад +1

    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

  • @divyeshkumarbalar7732
    @divyeshkumarbalar7732 Год назад

    Whats realtime application for shift operators?

  • @mohammednumanahmed3163
    @mohammednumanahmed3163 2 года назад

    love uuuuuuuuuuuuuu bhai

  • @asta5583
    @asta5583 3 года назад

    Thank yu

  • @malaak1h
    @malaak1h 7 лет назад +1

    what is the use of the left right shift operator?

  • @user-jr6zr9rc2w
    @user-jr6zr9rc2w 3 года назад +1

    Pls help
    Int a=64
    Byte b=(byte) (a

    • @mettagowtham9768
      @mettagowtham9768 2 года назад +2

      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

  • @159saur
    @159saur 5 лет назад

    Can you please explain unsigned right shift as well ?

  • @semplex9992
    @semplex9992 Год назад

    i love you

  • @kuldeepruletiya3146
    @kuldeepruletiya3146 7 лет назад

    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 ?

    • @aronblanche
      @aronblanche 4 года назад

      >> is signed right shift, >>> is unsigned right shift...i.e. >>> fills up 2's complement form of the number from right side

  • @blurmn9466
    @blurmn9466 4 года назад

    thanks, finally i found a good explanation

  • @shivanisoni5935
    @shivanisoni5935 5 лет назад

    Sir differen between >> $ >>>.
    Please tell...

  • @sachinkataria6667
    @sachinkataria6667 5 лет назад

    Sir what if the variable type is float in this example

  • @-arun-3397
    @-arun-3397 Год назад

    Why should we use this shift operator in java ? Tell me real life example for this ..

  • @adithyathota1688
    @adithyathota1688 9 лет назад

    it is use full

  • @smitkalsa6148
    @smitkalsa6148 5 лет назад

    How are you remember this all decimal numbers binary form ?

    • @ejajshaikh3704
      @ejajshaikh3704 5 лет назад

      It is 8421 code or formula
      1o1o this os binary of 10 decimal

  • @ragavendravignesh1028
    @ragavendravignesh1028 5 лет назад +1

    can you explain this ">>>"

  • @alopradocai
    @alopradocai 2 года назад

    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.

  • @jvjplus
    @jvjplus 8 лет назад

    What's the difference between >> and >>>

    • @screwedidiot937
      @screwedidiot937 8 лет назад +1

      >> (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

  • @venkateshyadavvanguri959
    @venkateshyadavvanguri959 8 лет назад +1

    how to convert numbers to boolean

  • @AbhiShek-nv3vq
    @AbhiShek-nv3vq 8 лет назад

    Great

  • @mk9834
    @mk9834 5 лет назад +1

    wow i dont know this exists!

  • @sandeepsahu8743
    @sandeepsahu8743 7 лет назад +1

    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?

    • @maff1917
      @maff1917 6 лет назад

      Because you shift from right to left

    • @zeeshantunio3390
      @zeeshantunio3390 5 лет назад

      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

    • @smile-me2ik
      @smile-me2ik 5 лет назад

      Coz We perform any operation on binary from left..... Moreover no. Has to be shift left..... So wont u apply force from right😉

  • @sanjaikumar1572
    @sanjaikumar1572 6 месяцев назад

    100 - 1100100
    100 >> 5
    Answer is 4 How?

  • @mollybaihuichen1213
    @mollybaihuichen1213 3 года назад

    how is 1000 8?

  • @राजनगोंगल
    @राजनगोंगल 5 лет назад

    👍👍👍

  • @s.krishnabharaths.krishnabhara
    @s.krishnabharaths.krishnabhara 5 лет назад

    How to covert a number into binary number any one help me plzz

  • @mohdwaseem-zu9jl
    @mohdwaseem-zu9jl 2 года назад

    👍

  • @gvenkatesh8935
    @gvenkatesh8935 4 года назад

    Teluskunnanu sir

  • @agourav220
    @agourav220 8 лет назад

    ty ty helpullll

  • @be.nandya
    @be.nandya 3 года назад

    8 ko 1000 me kaise convert kiya

  • @Matilda32664
    @Matilda32664 4 года назад

    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

    • @dhritiayusj2710
      @dhritiayusj2710 3 года назад +1

      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

    • @BoredStory
      @BoredStory 3 года назад

      @@dhritiayusj2710 yeah it applies on games and high specs softwares

  • @sachinjagarwar
    @sachinjagarwar 7 лет назад

    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

  • @md.shorifulislam1348
    @md.shorifulislam1348 6 лет назад

    gd

  • @naveetraj506
    @naveetraj506 19 дней назад

    Bcs306a 😂

  • @cantastic
    @cantastic 7 лет назад

    sounds like a guy from a hotline

    • @cantastic
      @cantastic 7 лет назад

      nvtheless amazing video!