In: Computer Science
1.
Assuming A equals the binary value 10101010 and B equals the binary value 11110000, the result of the bitwise-OR of A with B is?
Just enter the 8-bit binary number that represents the result of the operation. Do not add any spaces, decimal points, commas, or base-2 subscript. Do not delete leading zeros.
2.
Assuming A equals the binary value 10101010 and B equals the binary value 11110000, the result of the bitwise-XOR of A with B is?
Just enter the 8-bit binary number that represents the result of the operation. Do not add any spaces, decimal points, commas, or base-2 subscript. Do not delete leading zeros.
3.
Assuming A equals the binary value 11110000, the result of the bitwise inverse of A is?
Just enter the 8-bit binary number that represents the result of the operation. Do not add any spaces, decimal points, commas, or base-2 subscript. Do not delete leading zeros.
What are Bitwise operators :
Bitwise operators perform functions bit-by-bit on either one or two binary numbers. They make use of boolean logic operating on a group of binary symbols. These bitwise operators are widely used throughout both electronics and programming.
Bitwise Operators(AND,OR,XOR) are used to perform bit manipulation operations on one or two full binary numbers. Bitwise operation uses boolean logic operation on a group of binary symbols.
1. BITWISE-OR:
OR produces union of two numbers, If either or both bits are 1, the
value of the result at that bit-position is 1. If both values have
a 0 at that position, the result also gets a 0 at that
position.
the four possible OR combinations, and their outcome are:
0 OR 0 = 0
0 OR 1 = 1
1 OR 0 = 1
1 OR 1 = 1
Based upon above logic,
For A = 10101010 and B = 11110000, Result of Bitwise-Or will be: 11111010
Explanation:
A OR B
Bit 8: 1 OR 1 = 1
Bit 7: 0 OR 1 = 1
Bit 6: 1 OR 1 = 1
Bit 5: 0 OR 1 = 1
Bit 4: 1 OR 0 = 1
Bit 3: 0 OR 0 = 0
Bit 2: 1 OR 0 = 1
Bit 1: 0 OR 0 = 0
2. BITWISE-XOR:
XOR mean exclusive OR. XOR is like OR but it only produce a 1 if either one or the other numbers has a 1 in that bit-position.
The four possible XOR combinations, and their outcome are:
0 XOR 0 = 0
0 XOR 1 = 1
1 XOR 0 = 1
1 XOR 1 = 0
For A = 10101010, B= 11110000, Result of Bitwise-XOR will be: 01011010
Explanation:
A XOR B
Bit 8: 1 XOR 1 = 0
Bit 7: 0 XOR 1 = 1
Bit 6: 1 XOR 1 = 0
Bit 5: 0 XOR 1 = 1
Bit 4: 1 XOR 0 = 1
Bit 3: 0 XOR 0 = 0
Bit 2: 1 XOR 0 = 1
Bit 1: 0 XOR 0 = 0
3. BITWISE INVERSE:
If the current bit is set i.e. 1 than invert it to 0 and vice versa
The possible outcome:
1 = 0
0 = 1
For A = 11110000, Result Bitwise inverse will be: 00001111