You are not logged in.
Pages: 1
If I have an integer with the value, lets say 2. How can I print the bit representation to screen?
Orjanp...
Ørjan Pettersen
Offline
The only way I know of is going bit by bit and applying a bit mask that shows the value of that bit, like your_integer & bit_mask_for_bit_X.
Offline
edit: ok wtf it won't let me print it
basically have a for loop uptil 32 printing out your number shifted right each iterationg, num >> i, where i = 0 .. 31
Offline
you can print it as hex or octal - and from there conversion to bits is easy
Offline
Offline
Pages: 1