Bitwise Right Shift Operator in Python

Python Programming: Bitwise Right Shift Operator in Python
Topics discussed:
1. Introduction to Bitwise Shift Operators.
2. Bitwise Right Shift Operator.
Python Programming Playlist: • Python Programming
Follow Neso Academy on Instagram: @nesoacademy (bit.ly/2XP63OE)
Contribute: www.nesoacademy.org/donate
Memberships: bit.ly/2U7YSPI
Books: www.nesoacademy.org/recommend...
Website ► www.nesoacademy.org/
Forum ► forum.nesoacademy.org/
Facebook ► goo.gl/Nt0PmB
Twitter ► / nesoacademy
Music:
Axol x Alex Skrindo - You [NCS Release]
#PythonByNeso #PythonProgramming #OperatorsInPython

Пікірлер: 17

  • @li0770
    @li077011 ай бұрын

    Thanks a lot. I hope you could explain about passing function as arguments of another function without including the parentheses, it's a tough topic for me

  • @rajeshprajapati1851
    @rajeshprajapati1851 Жыл бұрын

    He has already done a great work in C language and now this.

  • @sunset2193
    @sunset2193 Жыл бұрын

    Nice explanation bro could please do SQL entire topic please brother

  • @TribhuvanMahath
    @TribhuvanMahath8 ай бұрын

    Thanks

  • @markuche1337
    @markuche133711 ай бұрын

    Awesome explanation thanks ❤

  • @user-iq8ll9op2y
    @user-iq8ll9op2y22 күн бұрын

    it is working odd num or not?

  • @majjiharish4165
    @majjiharish4165 Жыл бұрын

    upload in module and error concept

  • @intelinside1473
    @intelinside14735 ай бұрын

    >>> a=-12 >>> bin(a) '-0b1100' But in video 8:36 10100 = -12? Can anyone explain that pleace?

  • @big-jo89

    @big-jo89

    3 ай бұрын

    because when you use the bin() function in Python to represent a negative integer, it returns the binary representation of the positive magnitude of that number, but with a leading '-' sign to indicate that it's a negative number of the same positive number. for example number 12 if we run >>> bin ( 12 ) it return '0b1100' == the binary representation of the positive 12 but when we run >>> bin ( - 12 ) it return '-0b1100' == the negative representation of the positive 12 but not in the actual binary representation of ( -12 ) which is '0b 1111 0100' I guess python choose to represents negative integers using two's complement notation is to maintain consistency and simplicity in its representation of integers, as this approach aligns with how integers are typically represented and manipulated in computer systems.

  • @rajisam4802
    @rajisam48025 ай бұрын

    if the division results in float values what should be the result??

  • @satishgokul7176
    @satishgokul71769 ай бұрын

    @9:06 didn't understood how the shift occurs it should be 01010 instead 11010. please anyone correct me if i was wrong

  • @pmalik1975

    @pmalik1975

    8 ай бұрын

    Yes I also feel the same

  • @big-jo89

    @big-jo89

    6 ай бұрын

    because the leftmost bit indicates the sign (0 for positive, 1 for negative) in a 2's complement system. so you shift the actual bits not the bit which represent the number's sign. in this case, 1 is the most left bit which means that the number is negative. so for systems and compilers to differentiate between positive and negative number they put 0 or 1 in front of the binary to indicate its sign for the hardware can then work with them

  • @vonSmash

    @vonSmash

    3 ай бұрын

    ⁠@@big-jo89​​⁠​⁠​⁠​⁠yeah that’s true. My confusion though is that I thought that after the 2nd shift the binary would be 10101 not 11101. Because if we remove the sign number for a second, after the first shift we had 1010, right? Then if we shift it a second time it should be 0101, no? Or what am I missing? 😅

  • @big-jo89

    @big-jo89

    3 ай бұрын

    @@vonSmash sorry but I didn't get what you mean

  • @vonSmash

    @vonSmash

    3 ай бұрын

    ​@@big-jo89 Yeah, I see that my question was a big badly formulated.. 😄 haha! let me try again. At 04:00 we first see him explaining the shift of the positive number 12 which is equal to 01100. If we just remove the sign number 0 here to make it a bit clearer then we have 1100, right? He then shows the first shift which goes from 1100 to 0110, and this makes sense to me because it looks like the 0 that was all the way to the right has now moved to the start on the left. Then the second moves is like I expected too, from 0110 to 0011. However, my confusion starts at 09:03 when he shows the negative numer, -12 = 10100 (remove the sign and we have 0100). Because when he show the first shift it goes from 0100 to 1010. Where did that extra 1 come from? And the same in the second shift, from 1010 to 1101. There is now three 1's. It feels like I've missed an explanation from him in the video but even after rewatching I can't understand it. Does my confusion make sense, and can you see what I'm getting wrong? Maybe my assumption is wrong form the start but don't know what I should assume otherwise 😅