-
XORs r' us
Okay, the following 2 examples provide different answers. Why?
'correct according to the book, (^^ = XOR) but wrong answer
' it results in rb_change being $ff always
rb_change = rb_read ^^ rb_save
' wrong according to the book, (^ = nothing) but right answer, rb_change becomes an xor of the two variables
rb_change = rb_read ^ rb_save
Here is the acutal code:
while 1 ; continue forever
rb_read = portb >> 4 ' get the 4 inputs into the right nibble
rb_channel_change = rb_read ^ rb_save ' if one changed, get it into rb_channel_change
rb_save = rb_read ' save the data for the next time around
if rb_channel_change then
gosub test_change ' a channel changed
endif
wend
What am I missing?
-
A single caret ^ is a Bitwise operator.
Double caret ^^ is a logical operator resulting in a True or False answer.
hth,
-
Thanks Darrell. It makes sense now.
Lost a couple hours on that one.
-
Just a couple hours?
Crap, I thought that would have been frustrating enough to warrant a ride on the bike.
Oh well, tomorrows Saturday, that's good for a ride even when not frustrated. :)
<br>
-
Gone for a ride. Maybe tomorrow as well.