Bitwise AND two numbers, and compare different bit positions for equality.
Anonymous
Bitwise AND two 8 bit numbers For each of the 8 bits, if both bits in the two numbers are one, the resulting bit is one, otherwise zero. Example: 0xD5 & 0x3E = 11010101 & 00111110 = 00010100 = 0x14 ---------------- Write a function on the board that compares the 7th position in an 8 bit binary number to the 4th position in another 8 bit binary number. Return true if equal. !(((0x40 & a) >> 6) ^ ((0x08 & b) >> 3)) (Note: first number represented by 'a', second number represented by 'b') Explanation: Mask off the indicated bit in each number with a bitwise AND. Shift that bit to the first bit location. Perform a bitwise exclusive OR between the two bits (if the bits are the same, the answer will be zero). Perform a logical NOT to convert a zero to TRUE.
Check out your Company Bowl for anonymous work chats.