Bitwise Operators 1: The AND Operation
Вставка
- Опубліковано 25 січ 2020
- This computer science video describes the bitwise operation AND. It explains how the AND operation works with unsigned integers and how the bitwise AND operation can be used to determine whether an integer is positive or negative. It also shows how the AND operation can be used with a bitmask to manipulate the contents of a register containing bit flags. The equivalent AND operators are demonstrated in VB.NET, JavaScript and Python.
I used bitwise AND for a maze program I made. Every cell had an integer value for the exits. North = 1 East = 2 South = 4 West = 8. When the player tried to go up, I did a check of cellExits AND 1. If it was 0, the player could go north. No wall there. For west it was cellExits AND 8. If it returned 0, it was good to go. No wall there. Much easier than checking if canGoNorth = True for every direction and every cell.
It took you 2 minutes and 35 seconds and the light bulb clicked. Thank you so much!!!
I was reading the C Programming Language by K&R and then I got stuck at the Bitwise Operator section. Your series saved me THANK YOU sir
Delighted to help :)KD
Really helpful, thank you so much. The example with the rooms is perfect for that! Helped me a lot! 🙏
Thank you. Straightforward and informative.
You're welcome :)KD
This was SO helpful! Thank you!
You are most welcome :)KD
Thank you so much sir for this clean explanation
You are very welcome. Thanks for the comment. :) KD
thank you for the material and great way of presentation. quick question: why need to apply a mask when it is already clear which room has heat turned on?
Thanks
Really helpful
Thanks so much. This is a better explanation than my assembly language instructor was able to provide lol
Thank you
I finally get it!!! (More importantly, I finally get WHY this is useful!)
Excellent. They WHY is so important when you are learning something. :)KD
Thank you for a the great explanation. Could it be that there slipped a minor error on the upstairs heaters check? That one would not show that all downstairs heaters are off, since even if they were on, the result of the bitmask comparision would be the same, wouldn't it?
You may well have spotted a 'typo'. Thanks for the heads up. I'll take a look. :)KD
Now this is Epic Sir
Thank you for the lovely comment. :) KD
Thank you Jarvis
For you sir, always :)KD
thanks sir
You're welcome
Sir, please make videos on michroprocessor and computer organization and architecture
I'm working on memory address decoding at the moment. Please watch this space. :) KD
@@ComputerScienceLessons okay sir..
First view !!! and first Comment !!!!!
Welcome. :) YT should start giving prizes or something.
@@ComputerScienceLessons haha yeah, cheers - and thanks very much for posting this great content.