Bitwise Operations & Bit Masking

Поділитися
Вставка
  • Опубліковано 20 лип 2024
  • In this beginner's tutorial we take a look at Bit manipulation through the use of bitwise operations and bit masking.
    You can find worksheets and more resources for students and teachers over on my website at:
    learnlearn.uk/alevelcs/bitwis...

КОМЕНТАРІ • 39

  • @danha3107
    @danha3107 Рік тому +14

    I've spent so long trying to understand this on my own, with my prof, and with other videos but none made it click as easily as this one. Thank you so much

    • @chronosbat
      @chronosbat Рік тому

      Same. I literally have a paragraph and 1 practice problem to try to write masking code 😭

  • @rilsosingkoireng1492
    @rilsosingkoireng1492 2 роки тому +13

    the cleanest and best explanation ever on bit masking. great job!! thank you appreciate your hard work.

  • @huyennguyenmaingoc468
    @huyennguyenmaingoc468 3 місяці тому +2

    thank you for your explanation XD I have been searching for Bitwise explanation and this is the best video I ever seen.

  • @haojiang4882
    @haojiang4882 3 роки тому +5

    This is by far the clearest explanation on bit masking I have watched. Thank you so much. Subed.

  • @siomarapantarotto
    @siomarapantarotto 2 роки тому +2

    Fantastic! I loved your tutorial. God bless you! Best content explaining bitwise that I found on the Internet. 🥰

  • @marnierogers3931
    @marnierogers3931 2 роки тому +3

    This video has saved my life. Have spent a few hours trying to decipher what my lecturer explained and this has cracked it. Thanks!

  • @goodhabits1805
    @goodhabits1805 2 роки тому +2

    So clearly summarized! Amazing! Thank you so much!

  • @tachikoman9462
    @tachikoman9462 2 роки тому +2

    The clearest explanation!!! Appreciate it so much!

  • @Shuchrid2
    @Shuchrid2 Рік тому +1

    THIS IS FANTASTIC!
    Oh my god, you explained it so elegantly - I understood everything immediately!!!
    do note that on the last example (Clearing digit 5 to 0), the table showes a XOR gate table, instead of the OR gate table (:

  • @flokipanda
    @flokipanda 9 місяців тому

    Best tutorial on bitwise operators.

  • @tarassavchenko2317
    @tarassavchenko2317 2 роки тому +1

    thank you!really clear explanation

  • @dylanngo4454
    @dylanngo4454 2 роки тому +1

    Thanks, It's simple to understand

  • @lancemarchetti8673
    @lancemarchetti8673 Рік тому

    Great Explanation. I recently wrote a .js file that carries out a Bitwise NOT on a negated string and outputs it as Base64.

  • @HappyLife-fz8uu
    @HappyLife-fz8uu 2 роки тому

    Thankyou so much! Your video saved my broken brain 👍🫶🏻

  • @aaaminahammm4365
    @aaaminahammm4365 2 роки тому

    Finally, i learned masking
    thank you

  • @cristidragosmatei
    @cristidragosmatei Рік тому

    Outstanding, thank you

  • @dcy9846
    @dcy9846 2 місяці тому +1

    For clearing bits, wouldn't you be able to use an AND instruction and use a mask that has all 1's but the ones you want to clear? 1111 0101 AND 1110 1111 would result in the same thing but in less operations since the other bits would remain the same?

  • @fionaleclair-robertson8998
    @fionaleclair-robertson8998 2 роки тому +1

    worth more than 400 views amazing vid

  • @TresorElf
    @TresorElf 7 місяців тому

    you are a livesaver man

  • @georgesmith9178
    @georgesmith9178 Рік тому

    i am surprised you got very few likes over the 2 years this video has been on. Thumbs-up of course. Just three tips: 1. Don't point with your mouse - draw a rectangle or a circle around what you are trying to highlight. Your mouse pointer is small and learners have trouble tracking it (I asked several and we all agree :) ). 2. Please, put the word description of the bitwise operation next to its symbol, e.g., NOT !, AND &, etc. 3. For the last, more involved example, I would follow your explanation with a simplification: First, flip all original bits, then flip only the target bit (with an OR | mask), and finally flip everything in the masked result back (with a NOT !). Only the targeted bit ends up different from all the original bit we started with.
    This explanation just helps learners shift their attention from the very visible 0s and 1s to the way less visible Data, flipped, Mask, OR result, and Flipped back labels on the very right, which is probably what you want them to focus on. I would also draw two red rectangles around original target bit in the starting binary value and that bit in the final result. Best of luck. I know you will do great :).

    • @learnlearnscratch
      @learnlearnscratch  Рік тому

      Thank you very much for the tips!!! I'll make sure I incorporate them into future videos!

  • @pareshkumar6268
    @pareshkumar6268 Рік тому +1

    Thank u soo much bro!! understood everything on the first go

  • @jemuelespiritu1641
    @jemuelespiritu1641 3 роки тому

    thank you very much sir

  • @OneLordeAnimeClips
    @OneLordeAnimeClips Рік тому

    The first 4 minutes of this video did a better job explaining than a 45 minute lecture (and the convoluted ass explanations in the textbook).

  • @PiyushLaad1987
    @PiyushLaad1987 Рік тому

    Thank you :)

  • @kkh0101
    @kkh0101 Рік тому +2

    clearing a digit to 0 could be done with &= ~FLAG operation.

  • @nekosquealer3423
    @nekosquealer3423 2 роки тому

    THANKS A LOTTT

  • @abhijeetpatil5170
    @abhijeetpatil5170 Рік тому

    Don't know for sure but can you check indexing of bits .

  • @smellysox16
    @smellysox16 3 роки тому

    Nice

  • @blazingfest5885
    @blazingfest5885 8 місяців тому

    could you also use a bitwise AND with a flipped mask to clear a digit to 0?

  • @q12x
    @q12x Рік тому

    Excelent explained ! Why? because you used examples !

  • @user-kc4eu3ks5r
    @user-kc4eu3ks5r Рік тому +2

    First of all, The subject is well explained and the use of examples was great.
    But, my question is, in the last part of the video, why do we need to flip twice instead of doing
    1111 0101 DATA
    &
    1110 1111 MASK
    ----------------
    1110 0101 RESULT

  • @SayheeKim
    @SayheeKim 10 місяців тому

    why can't you just do a AND mask to clear a bit to 0?
    input _ _ _ _ _ B _ _ _ _
    AND mask 1 1 1 1 0 1 1 1 1
    ----------------------------------------------
    result _ _ _ _ 0 _ _ _ _ right? (bit B is cleared to 0 and all other bits are preserved?)

  • @cvntdav
    @cvntdav Рік тому +1

    Here is a Rust example of 3:17 or 5:05 :D
    fn main() {
    let x = 0b1011; // Byte
    let y = 0b1000; // What bit?
    println!("{:b}", x & y >> y -1)
    }