Bitwise Addition ORGiven two binary strings, return their sum (also a binary string). GFG. Code Algo: Sum = a XOR b XOR c Carry = (a AND b) OR ( b AND c ) OR ( c AND a ) Binary to decimal Code Image Decimal to Binary Code [Pending] Add two numbers without using arithmetic operators. GFG Code… Continue reading Problem on Bit Operation
Generate 0 and 1 with 25% and 75% probability. Given a function rand50() that returns 0 or 1 with equal probability, write a function that returns 1 with 75% probability and 0 with 25% probability using rand50() only.
Read This. XOR is like cheating on your girlfriend: if you are alone with her it is ok, if you are alone with the other chick is ok, if you with none or with both you are screwed. Properties of XOR Here are several useful properties of XOR. This applies to plain XOR and bitwise… Continue reading XOR