Given implent 10010101 Flip bits in positions 047 using and
Given implent 10010101
Flip bits in positions 0,4,7 using and, or , xor gates methods. Please show all work
O,Solution
As far as I know XOR is used to toggle bits
(1<<4) ^ 10010101 = 10000101 [ Fourth bit is Flipped ]
(1<<7) ^ 10010101 = 00000101 [ Seventh bit is Flipped ]
(1<<0) ^ 10010101 = 10000100 [ Zeroth bit is Flipped ]
Normally OR is used to set a bit
If we want to use AND , OR combined for flipping we can use in this way
=> (10010101 & ~(1<<4 ) ) | ( ~(10010101) & (1<<4 ) )
= > 10000101 | 0000000
=> 10000101 [ Fourth bit is Flipped ] Similarly for 0 and 7
Thanks, let me know if there is any concern.
