I’m beginner with C and I am learning on my own.
I am trying to convert an int to binary for bitwise operations, and I am not really sure how to do it? I have tried to use mod and other mathematics to do it, but I have been unsuccessful. I have searched around and have not found a clear way of this. Please assist.
I’m beginner with C and I am learning on my own. I am trying
Share
You don’t need to do any conversion of an
intto use bitwise operators on it. They automatically work on the bits that compose theint.If you want to view the binary representation of a number, you can use (assuming the 8 least significant bits)…
CodePad.
This uses bitwise operators
>>(right shift) and&(and).