This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

bit (and sbit) operation with == and != (bug?)

I have a problem that i cannot solve.

I need to compare two bit values.
Lets say:

bit Low = 0;
bit High = 1;

But I get some really strange results if I try to compare both of them:

Low == High will result in a 0
Low != High will also result in a 0 (expected 1)
High == Low will result in a 1
High != Low will also result in a 1 (expected 0)

(a compare with a constant like Low == 0 will work correctly)

It semms that I allways get the value of the first bit, but not the value of the comparison.
Same here with sbit operations.

But the C51 User Guide tells me:
~~~
The following operations may be executed with bit-type operands:
[...]
Compare bit with bit or constant (==, !=)
~~~

So whats the problem here ?

Parents Reply Children
No data