Python's bitwise operations: What they are, how they work, and how to use them

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ธ.ค. 2024

ความคิดเห็น • 86

  • @codezamacodinglabs
    @codezamacodinglabs ปีที่แล้ว +1

    You have beautifully explained them. kudos to you. Thanks alot

  • @th2315
    @th2315 ปีที่แล้ว +2

    dude the way you explain everything is amazing, and easy to understand, I appreciated it!

    • @ReuvenLerner
      @ReuvenLerner  ปีที่แล้ว

      I'm so glad to hear it helped!

  • @necromeo-dev
    @necromeo-dev 3 ปีที่แล้ว +2

    Best bitwise operators explanation on YT. By far!

  • @jayhiryu2139
    @jayhiryu2139 4 ปีที่แล้ว +6

    Thank you i pick this up literally seconds after you explained

  • @billybuck2713
    @billybuck2713 2 ปีที่แล้ว +2

    Great video!

  • @Chris-sj4wb
    @Chris-sj4wb 2 ปีที่แล้ว +1

    genuinely fantastic video

  • @SolomaZed
    @SolomaZed 3 ปีที่แล้ว +5

    I am happy I found this! this cleared up a lot of my confusion on bitwise operators. thank you Reuven, great and clear explanation on the topic!

  • @Grotesque18
    @Grotesque18 3 ปีที่แล้ว +2

    Great explanation, clear audio and awesome enthusiasm. I will be back for more videos!

    • @ReuvenLerner
      @ReuvenLerner  3 ปีที่แล้ว

      Delighted to know it helped!

  • @itsobviouswho
    @itsobviouswho ปีที่แล้ว

    Thanks! Out of all the videos I browsed on this topic, this was by far the most informative. 🙂

  • @greggreen5510
    @greggreen5510 2 ปีที่แล้ว +2

    Very well explained! The font size was not an issue for me. You did a wonderful job explaining these concepts. Thank you!

    • @ReuvenLerner
      @ReuvenLerner  2 ปีที่แล้ว +1

      Thanks for the kind words, and I'm delighted you enjoyed!

  • @nguessanbenie2487
    @nguessanbenie2487 2 ปีที่แล้ว +1

    Oof what a relief to have found this at 1 am. Thank you very much. If I am not going to use it, at least I can explain it to someone else.

    • @ReuvenLerner
      @ReuvenLerner  2 ปีที่แล้ว

      I'm delighted to hear that it helped!

  • @ngamsomset
    @ngamsomset 2 ปีที่แล้ว +2

    Very well explain! I struggle with Bitwise a lot when I found it in the book(datastructure and algorithm with Python) and I wondering when I'm gonna use this. Now it's clear. Thanks!

  • @fernandes1431
    @fernandes1431 2 ปีที่แล้ว +1

    Can't thank you enough for finally helping me to understand bitwise. I've being trying to clean sdss data and they have badflags which require removing. It was driving me crazy haha.

    • @ReuvenLerner
      @ReuvenLerner  2 ปีที่แล้ว +1

      So happy to hear that it helped!

  • @andrewmcmanus3481
    @andrewmcmanus3481 3 ปีที่แล้ว +1

    Thank you so much for this video!

  • @ifeanyianene6770
    @ifeanyianene6770 2 ปีที่แล้ว +3

    I came for bitwise operations explanations and I'm pleased to find this. However, my main critique would be that you should explain how to go from decimal (13) to binary for someone new/unfamiliar.

    • @ReuvenLerner
      @ReuvenLerner  2 ปีที่แล้ว +1

      Fair enough -- I'll try to do a video about different number bases, and how they work.

    • @ifeanyianene6770
      @ifeanyianene6770 2 ปีที่แล้ว +1

      @@ReuvenLerner yeah just thinking about it again, I guess the main point of the video was really bitwise operation. I was just a little salty 😅 cause I really loved the way you explained the decimal expression of (1234) and I wanted to see that with decimals. Wonderful vid nevertheless.

  • @anyalauria1364
    @anyalauria1364 2 ปีที่แล้ว +1

    Great video, and you are a very engaging teacher!

  • @hosnymubark6528
    @hosnymubark6528 3 ปีที่แล้ว +2

    One of the best explanations so far.
    Thank you :)

  • @yuriipylypiv2117
    @yuriipylypiv2117 ปีที่แล้ว +1

    Thank you so much!

  • @TheAfreitag
    @TheAfreitag 3 ปีที่แล้ว +1

    Never thought I'd need to learn this subject. But here I am, and thank goodness for your excellent explanation. BTW I was at pycon Cleveland 2018 too !

  • @DanielSposito
    @DanielSposito 4 ปีที่แล้ว +2

    Excellent overview and examples - thank you!

  • @jgabnd
    @jgabnd 2 ปีที่แล้ว +1

    My question is about the & operator: why does 0b1100 & 0b0110 not set the output to 0b0100 but to 0b100? Is it because the operands have 4 binary digits instead of 8? Thank you very much for this course.

    • @ReuvenLerner
      @ReuvenLerner  2 ปีที่แล้ว +1

      There's no difference between 0b100 and 0b0100. In decimal numbers, there's no difference between 123 and 0123; leading zeroes don't affect things. The same is true for binary numbers.

    • @jgabnd
      @jgabnd 2 ปีที่แล้ว +1

      @@ReuvenLerner Thank you Sir ! Disregard my question on Linkedin Python community. You gave me the answer.

  • @_emanmodnar
    @_emanmodnar ปีที่แล้ว +1

    How do you deal with bytes, that are going LSB-MSB in Python and MicroPython?

    • @ReuvenLerner
      @ReuvenLerner  ปีที่แล้ว +1

      I believe that all of the bytes are standardized once they get to Python, but I could be completely wrong about that. I'll see if I can find out.

    • @_emanmodnar
      @_emanmodnar ปีที่แล้ว

      @@ReuvenLernerThat would be great. I can't find any useful material about how to approach this...
      I'm facing a problem when receiving a IR-signal where the protocol is LSB>MSB. The signals are having variable bit-lengths (some signals could be 8 bits long, others 14 bits), which complicates things a lot.. I need to reverse the stream, however this isn't an easy task, because MicroPython removes the leading zeroes - for instance: 0b00001010 should become 0b01010000, but MPy sees the incoming as 0b1010 which then becomes 0b101 when it is reversed (instead of 0b01010000). It's a simple task to reserve the numbers, if I interpret it as a string instead of binary int - however this seems like a potential buggy workaround, and would also lack bitwise operations.

  • @IRod123
    @IRod123 2 ปีที่แล้ว +1

    Great explanation! Thank you.

  • @MW-uq7we
    @MW-uq7we 2 ปีที่แล้ว +1

    Great explanation !! thanks for sharing your knowledge. respect !!

  • @LuisSanchezLouieLouie
    @LuisSanchezLouieLouie 4 ปีที่แล้ว +1

    You are a good teacher man

  • @muadzsofri5328
    @muadzsofri5328 2 ปีที่แล้ว +1

    it was both useful and interesting. thank you !

  • @devil_gamerplays
    @devil_gamerplays 2 ปีที่แล้ว +2

    Very well explained!!

    • @ReuvenLerner
      @ReuvenLerner  2 ปีที่แล้ว

      Thanks; I'm delighted it helped!

  • @pixieshine77
    @pixieshine77 4 ปีที่แล้ว +3

    I like the use of jupyter notebook here, much easier to follow along compared to the IDLE >>> environment that people often use where this symbol >>> is >>> everywhere >>>

    • @ReuvenLerner
      @ReuvenLerner  4 ปีที่แล้ว +3

      >>> Happy to hear it :-)

  • @OhsoLosoo
    @OhsoLosoo 2 ปีที่แล้ว +1

    I really enjoy the examples you use. I’m not sure if you have one, but a follow up video for tricks & tips using these in some more examples would be great! (It has been 2 years, so there might be a lot of this already out there 😅)

    • @ReuvenLerner
      @ReuvenLerner  2 ปีที่แล้ว

      I'm always making new videos, often based on ideas from the comments here... So I'll do some thinking, and see what I can do!

  • @Nassir_11
    @Nassir_11 3 ปีที่แล้ว +1

    This is very useful and interesting for me, I'm glad that I watched it 🤩

  • @cambridgebreaths3581
    @cambridgebreaths3581 3 ปีที่แล้ว +1

    Amazing. Thank you

  • @3dmikec88
    @3dmikec88 3 ปีที่แล้ว +1

    Very clear, thank you!

  • @prateekyadav7679
    @prateekyadav7679 2 ปีที่แล้ว +1

    This is fantastic, thank you!

  • @helderrezende2183
    @helderrezende2183 4 ปีที่แล้ว +1

    Great explanation!

  • @AhmadAli-jl3ll
    @AhmadAli-jl3ll 3 ปีที่แล้ว +1

    I need help: How can I find bitwise AND of two binary numbers without using the logical symbol '&'.

    • @ReuvenLerner
      @ReuvenLerner  3 ปีที่แล้ว +1

      You want to find the bitwise "AND" without using &? Why work so hard?
      Part of the point of Python is to do things the easy way. If you're trying to understand how bitwise "AND" works, then I can understand... but Python does this in C, which means that its implementation will almost certainly be faster (and probably *far* faster) than yours.

    • @saeeduchiha5537
      @saeeduchiha5537 3 ปีที่แล้ว

      Same boat here.. I am trying to write a python script but without using python!

    • @ReuvenLerner
      @ReuvenLerner  3 ปีที่แล้ว +1

      @@saeeduchiha5537 Um, you probably shouldn't do that...

  • @Filip_Phreriks
    @Filip_Phreriks 4 ปีที่แล้ว +1

    This helped me a lot.

  • @DeepEnd123
    @DeepEnd123 4 ปีที่แล้ว +1

    Very nice! Thank you.

  • @fartzy
    @fartzy 2 ปีที่แล้ว +1

    Great video man

    • @ReuvenLerner
      @ReuvenLerner  2 ปีที่แล้ว

      I'm glad you enjoyed it!

  • @antonioonwu8190
    @antonioonwu8190 3 ปีที่แล้ว +1

    Awesome Tutorial!!

  • @MikeWeaver
    @MikeWeaver 2 ปีที่แล้ว +1

    2 years late, but Thank you!!

    • @ReuvenLerner
      @ReuvenLerner  2 ปีที่แล้ว

      Delighted it helped you! (And that's the beauty of TH-cam videos -- they stick around, and are there whenever you need them.)

  • @SPeeDKiLL45
    @SPeeDKiLL45 2 ปีที่แล้ว +1

    exactly what i needed.

  • @Naz-yi9bs
    @Naz-yi9bs 3 ปีที่แล้ว +1

    Amazing, thank you!

  • @olorcain
    @olorcain 3 ปีที่แล้ว

    So when I plug 130&130 into my python interpreter I get 0. I don't understand why, I would expect it to be a non zero integer

    • @ReuvenLerner
      @ReuvenLerner  3 ปีที่แล้ว +1

      When I type 130 & 130 into Python, I get 130, whic makes sense. I'm not sure how you're getting that result. Sorry!

    • @olorcain
      @olorcain 3 ปีที่แล้ว

      @@ReuvenLerner I tried a different interpreter and got 130. The backspace key wasn't working properly either in the other interpreter so perhaps something else is going on with it

  • @reystudio4317
    @reystudio4317 3 ปีที่แล้ว +1

    very useful!

  • @holyshit922
    @holyshit922 ปีที่แล้ว +1

    He uses jupyter notebook
    I would like to write one pseudocode in jupyter notebook but I dont know how

    • @ReuvenLerner
      @ReuvenLerner  ปีที่แล้ว

      Jupyter can be used to write code (typically, but not exclusively, in Python) or documentation (typically in Markdown). If you want to write pseudocode, go ahead and do it in Markdown -- but it'll just be seen as documentation, not actual code.

  • @killcode6717
    @killcode6717 2 ปีที่แล้ว +2

    Thanks

  • @nvmidiae
    @nvmidiae 2 ปีที่แล้ว +1

    thank u sir

  • @zahra-pl1sk
    @zahra-pl1sk 3 ปีที่แล้ว +1

    greaaaaaaaat !!! thnaks alot

  • @Janlaxle
    @Janlaxle 3 ปีที่แล้ว +3

    Thanks, now i know for sure that I will never use that )

  • @mousquetaire86
    @mousquetaire86 2 ปีที่แล้ว +1

    I feel slightly bad for liking this video -as it stopped the "likes" from totalling 404....

    • @ReuvenLerner
      @ReuvenLerner  2 ปีที่แล้ว +1

      Glad you liked it -- and there are other cool numbers out there!

  • @glorymanheretosleep
    @glorymanheretosleep ปีที่แล้ว +1

    Holy SHIT! You made it click for me! Thanks!

    • @ReuvenLerner
      @ReuvenLerner  ปีที่แล้ว +1

      I'm so delighted to know that it helped!