Bitwise Operations Basics
Until now, anytime we've performed an operation on 2 binary integers, they've always been arithmetic operations such as add or subtract. But these are not the only kind of operations we can perform on binary integers. Surprisingly, we can perform logic operations on integers too. These are referred to as bitwise operations, and in this video we'll see how such an operation is performed. Spoilers: it's not that difficult. We'll also see some examples showcasing what bitwise operations can be used for. Such as bit setting, clearing, and inverting. Now, for a first, how about some homework: Given an 8-bit number representing 8 heating elements throughout a house, arranged as follows: 7 - Upstairs Bedroom 1 6 - Upstairs Bedroom 2 5 - Downstairs Bedroom 1 4 - Upstairs Bathroom 3 - Downstairs Bathroom 2 - Kitchen 1 - Upstairs Livingroom 0 - Downstairs Livingroom Try and come up with masks that perform the following: - Identifies all upstairs heaters - Identifies all downstairs heaters - Identifies all bedroom heaters - Identifies all livingroom heaters - Identities all bathroom heaters - Identifies all other room heaters
Download
0 formatsNo download links available.