I need to write a macro that receives some variable as a parameter, and for each two consecutive bits with a "1" value, replace it with 0 bits.
For example: 10110100 will become 10000100.
And, 11110000-> 00000000
11100000-> 100000000
I'm having trouble writing this macro. I tried to write a macro that receives the wach bit and replaces it if the next bit is the same (and they are both 1), but it only works for 8 bits and it is very unfriendly ...
PS I need a macro because I am learning C, and this is an exercise that I found, and I could not solve it myself. I know that I can use a function to make it easy ... but I want to know how to do it with macros.
Thank!
source
share