To convert a decimal number into a binary number using bit masking, perform the following steps:
- Enter a decimal value. The decimal number entered is internally stored in the form of binary digits.
- Assign a number 1 followed by 31 zeros to a variable called mask.
- Mask each of the binary digits of the decimal number one by one, beginning from the most significant bit. Apply an AND operation between the binary digits of the entered decimal number and the binary digits in the mask variable.
- Right-shift the binary digits in the mask variable by 1 bit making it 0 1 followed by 30 zeros.
- Repeat this procedure. Apply the AND operation between the entered decimal number and the mask variable and the resultant binary digit is displayed ...