In this recipe, we will learn to convert a decimal number into a binary number by making use of a bitwise operator. Bitwise operators operate on the binary digits of a number and enable us to do precise manipulation as desired.
Converting a decimal into binary using a bitwise operator
How to do it…
To convert a decimal number into a binary number by making use of a bitwise operator, perform the following steps:
- Enter a decimal number. This number is internally stored in the form of binary digits.
- Isolate the least significant bit of the decimal number by applying a logical AND operation between the entered decimal number and value 1.
- The least significant bit that results from step 2 is stored in an array...