08-24-2009 11:34 AM
Hi,
I need to test each binary bits using following logic equation.
How do I do this?
((var & (1<<bit)) != 0)
For example
If var = 0111 and bit =2 (start from 0), so third bit of var is 1 and shift by two
are equal, this equation will yield TRUE for third bit.
Things I need to accoplish
1. I need to compare every binary bit
2. result should be in corresponing binary bit.
Can someone show me how?
thank you in advance,
Do
Solved! Go to Solution.
08-24-2009 11:47 AM
Sorry, I put to wrong equation.
Can we try this?
I need to set the bit using following equation
var |= (1<<bit);
08-24-2009 12:13 PM