On the Subject of Bitwise Operations
Nobody’s favorite kind of math. Who even likes math, anyway?
- There are 2 screens on the module:
- Bitwise operator (AND, OR, XOR, NOT)
- Result input
- Use the two bytes obtained from the tables below, and the operator from the first display, to determine the answer. In these tables, MSB is the most significant bit, LSB the least significant bit.
Byte 1 | Bit | Byte 2 |
---|---|---|
No AA batteries | MSB | 1 or more D battery |
Parallel port | 3 or more ports | |
Lit indicator NSA | 2 battery holders or more | |
More modules than you have (starting) time in minutes | Lit indicator BOB | |
More than one lit indicator | More than one unlit indicator | |
Number of modules divisible by 3 | Last digit of serial number is odd | |
Less than 2 D batteries | Even number of modules | |
Less than 4 ports | LSB | 2 or more batteries |
Here is a table of explanations of each bitwise operator:
Info | AND | OR | XOR | NOT |
---|---|---|---|---|
HOW | Going bit by bit, if both bits are 1, the return bit is 1. Otherwise, the return bit is 0. | Going bit by bit, if either (or both) bit is 1, the return bit is 1. Otherwise, the return bit is 0. | Going bit by bit, if either (but not both) bits are 1, the return bit is 1. Otherwise, the return bit is 0. | Ignore the second operand. Going bit by bit, the return bit is the opposite. |
MATH | bit1 && bit2 | bit1 || bit2 | (bit1 && !bit2) || (!bit1 && bit2) | !bit1 |