Problem on Bit Operation

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


Bitwise Operations

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.