Left and Right Shift

Поділитися
Вставка
  • Опубліковано 5 вер 2024
  • Learn how to multiply and divide by two in binary (or any power of two!)

КОМЕНТАРІ • 43

  • @bossgirl9176
    @bossgirl9176 4 роки тому +52

    I've got a computer science examination tomorrow and I found your video extremely helpful thank you

  • @DrMadPotato
    @DrMadPotato 7 років тому +79

    Teach better than my teacher! And it's such a simple thing

  • @theatomgamers3115
    @theatomgamers3115 8 років тому +24

    Got a computing exam coming up, This really helped, thanks mate.

  • @SunitaSharma-nc4zq
    @SunitaSharma-nc4zq 6 років тому +25

    I can't understand this topic in any of the lecture video but only this works thanks a lot for this simple nice and wonderful video
    I respect your teaching

  • @Abdulisbasith
    @Abdulisbasith 5 років тому +4

    Helped me clear so many doubts , Thanks Mr Powell's Computer Science Channel

  • @rubyc967
    @rubyc967 6 років тому +20

    Thank you so much!! This is so simple haha

  • @burgerking220
    @burgerking220 5 років тому +1

    Thank you very much.

  • @RishikaSinghthetraveler
    @RishikaSinghthetraveler 7 років тому +6

    Thanks very helpful

  • @zeefer9867
    @zeefer9867 6 років тому +2

    so clear, very nice,

  • @Shkencetari
    @Shkencetari 8 років тому +4

    Thank you very much :)

  • @khaldounal-nuaimi3594
    @khaldounal-nuaimi3594 5 років тому +2

    Thank you!

  • @NinjaCokeGaming
    @NinjaCokeGaming 6 років тому +1

    thanks Mr Powell!!!!!!

  • @Toturials
    @Toturials 6 років тому +1

    Thank you very much

  • @tpwk1282
    @tpwk1282 5 років тому +1

    Thank you so much for this

  • @lawalabdulateefolawale4548
    @lawalabdulateefolawale4548 5 років тому +1

    fantastic .......thanks

  • @hooramahi8441
    @hooramahi8441 6 років тому +1

    thanks very good video

  • @blackstreet23
    @blackstreet23 8 років тому +1

    Thanks this was really useful !!!!

  • @theo9743
    @theo9743 7 років тому +5

    whats the difference between a logical left shift and a arithmetic left shift?

    • @mrpowellscomputersciencech7120
      @mrpowellscomputersciencech7120  7 років тому +13

      There is no difference. There is however a difference for right shift. A logical right shift just shifts the bits along and fills the gap left at the left hand end with a zero - it is moving the place of the bits. An arithmetic right shift copies the most significant bit. This is useful when using two's complement numbers:
      -8 4 2 1
      1 1 0 0 - this is two's complement for -4
      0 1 1 0 - logical right shift has become positive 6- although it has moved the bit order
      1 1 1 0 - arithmetic right shift - the gap is filled with the old most significant bit. -4 right shifted has become -2

    • @asdf256
      @asdf256 6 років тому

      Thank you so much for explaining this simply. My professor doesn't teach us anything and the textbook is too in-depth.

    • @yagzyalcntas553
      @yagzyalcntas553 6 років тому

      Thank you for your answer been looking for this for half an hour and no ..... one does signed shifting! including you but at least in comments you did it. and another question if we do signed shift of positive number 0110 for example we will again copy msb which is 0 right? i havent came across any positive signed shifting made me question does signed mean negative or something...

    • @irenenastatchenko905
      @irenenastatchenko905 6 років тому

      msb will be copied anyway when using arithmetic right shift: either it is 1 or 0. The empty position in the most significant bit is filled with a copy of the original MSB.

  • @Dr_Ali.Aljboury
    @Dr_Ali.Aljboury 5 років тому +1

    Thanks for explaining. So may I know where we using these shifts and one more things how you make 5 or 10 after equal? Thanks

    • @mrpowellscomputersciencech7120
      @mrpowellscomputersciencech7120  5 років тому

      Binary shifts are used to quickly multiply / divide by powers of two. They can also be used to zero out lower or upper bits (although bitwise and would probably be better), they can also be used in binary multiplication. I am sure there are other uses. I am not sure I understand your second question.

  • @ahmedulhaquefuad280
    @ahmedulhaquefuad280 5 років тому +1

    64, 32, 16, 8, 4, 2, 1 for 7 bit

  • @shaheryarahmad5871
    @shaheryarahmad5871 6 років тому +1

    Good
    Easy to Understand

  • @bollyhunt7083
    @bollyhunt7083 7 років тому +1

    nice. and easy to understand

  • @jes2276
    @jes2276 6 років тому +1

    Have you done a rotate binary video?

  • @aura9654
    @aura9654 5 років тому

    thanks man
    helped a lot :)

  • @tanuj1253
    @tanuj1253 7 років тому +1

    What if you left shift the number 10 twice in hexadecimal(8 4 2 1)?

    • @mrpowellscomputersciencech7120
      @mrpowellscomputersciencech7120  7 років тому

      I am not quite sure what you mean. b10 as a binary number left shifted twice will be b1000 - or from 2 denary to 8 denary (and indeed from x2 to x8). If you mean x10 left shifted then x10 = b10000 and so left shifted is b01000000 which is x40 or denary 64. Lastly, if you are shifting places in hex then x10 would be x1000 which is whatever 16x16x16 is in denary.

  • @grainfrizz
    @grainfrizz 4 роки тому

    3

  • @naziasultana1860
    @naziasultana1860 5 років тому +2

    Thats my teacher

  • @sunlime3347
    @sunlime3347 6 років тому

    Thank you

  • @roushanraj2155
    @roushanraj2155 8 років тому +6

    thankssssssssssssssssssssssss

  • @michaelattard2634
    @michaelattard2634 6 років тому

    well done m8 very good enjoyed your lesson

  • @Rawoonah2cool
    @Rawoonah2cool 7 років тому

    At 2:37 when I tried to shift again I got 4 shouldn't I get 20?

    • @mrpowellscomputersciencech7120
      @mrpowellscomputersciencech7120  7 років тому +1

      If you use five or more bits to represent the number then you will get 20. In this case we were using just four bits which can represent the numbers 0-15 only - hence 20 won't fit in.
      If you left shift and have not got enough bits to represent the number then a computer processor will usually set an overflow flag. How to check for overflow varies between languages and architectures. The number of bits use to represent basic types like integers will vary too.

  • @mohithkumar9210
    @mohithkumar9210 5 років тому

    8 4 2 1 0 0 11 --> 3 --LS 1bit --> *2. This part is ok
    But if the register is has a fixed memory of 4 bit then the output should not go beyond 16, or you have an overflow, so for the above example it is necessary to restrict the operation to 2 left shifts only. Am i right?
    example: 8 4 2 1
    1 0 1 1 -->LS, 1 bit != *2.

    • @mrpowellscomputersciencech7120
      @mrpowellscomputersciencech7120  5 років тому

      It isn't necessary to restrict it to 2 left shifts, but you will lose data. Consider a 32 bit IP address 192.168.1.45. if I do ip > 24 then I get left with 45. If I want to check if the most significant bit of a number is a 1 then I could do if ((number1==number) {}. This isn't the most effective way to do it, but it does work.

  • @anoshaaziz7332
    @anoshaaziz7332 5 років тому

    nice

  • @tokihossoin7861
    @tokihossoin7861 6 років тому

    Safe bro