Python Bit-Wise Operations (Theory of Python) (Python Tutorial)

preview_player
Показать описание
Although we don't use bit-wise operations very often, it's important to know them. We're going to cover and, or and xor, as well as inversion. We're also going to cover 2's complement to understand how Python organizes bits of memory to store integers. We're also going to lightly touch on what these bitwise operations are used for.

Thank you!
Рекомендации по теме
Комментарии
Автор

I went through so many tutorials. this is the only one that clearly explained the operations clearly...

Sam-jgzv
Автор

I study Python and with this video i finally understand about bitwise .
thank you so much.

renato_cruzalegui_cruzalegui
Автор

Finally a video about Bitwise not made in India..
This channel deserves a lot more views.

wlfgang
Автор

My first video on your channel...really good explanation and content here for Python. Thank you so much and I'm definitely gonna subscribe. 😄

ireen
Автор

It took me a long time to realize we don't really care how many bits that Python uses to store our different int values, I kept thinking that it would affect the results of some bit-wise operations. It appears it does not, as long as it reserves one bit for sign extension in the case of positive numbers...
If it stored 3 simply as 11, then ~3 would give 0.
But ~3 gives -4, because it stores 3 as 011, so ~3 yields 100 which is -4 in two's complement.
Storing 3 as would still yield -4 when complemented.
Same thing with 5, if it stored it as 101, ~5 would give 2.
But it is stored as 0101, so whether we did that or 0000_0101, ~5 gives us -6.
Basically it stores every int in two's complement form, which requires one more bit than would be required if it stored it as an unsigned.
Or, it takes up more of them...it never changes the results we get back for bitwise operations, because, basically...sign extension for the win. I had to look at all of them to be comfortable with this...

jvsnyc
Автор

When you are teaching, i feel like im back in school. Your videos are very helpful. Thank you for your hard work

pixoloanimation
Автор

This is some deep stuff that I don't understand, but I like it and I'm very interested in understanding it.

MauriceWilliams
Автор

Thanks, I never had anyone explain this to me before.

Small point, my understanding after puzzling on it a bit is that a negative number say -n get's represented as bin(2**32 - n)

so to get the binary rep of -12, I guess should write & -12)

carlmerrigan
Автор

at the end the music behind the scene... Fryderyk Chopin - fantstic!

przemeknawrocki