Hello Dave,
For reference:
f1 is a long
f2 is a long
here's the statement
f1 = (f1 or f2)
I'm curious what the "OR" is doing here. I assume it's some type of
comparison and reassignment based on the comparison but like I said,
I'm not sure I've ever seen this type of operation before and would
like someone to try and explain what's going on here.
Imagine that before this statement the following is true.
f1 = 7 = 00000111 (bin 7)
f2 = 24 = 00011000 (bin 24)
the statement says set f1 equal to a value equivilent to the ORing of both
values.
ie if the f1 has a 1 in a given position OR f2 has a 1 in that same position
then the output value should have a 1 in that same position
f1 therefore becomes 00011111 = 31
in this case it appears to have resulted in addition
However.... imagine that the figures were 15 and 28
15 = 00001111
28 = 00011100
f1 = 00011111 = 32
32 is definitly not the result of adding 15 and 28
It can be looked on as the combination of flags.
It looks like in you example code.... someone was trying to flip all the
bit on in f1 which were on in f2 without turning off any of the bits which
were already on in f1.
Also be on the lookout for code which uses the AND (bitwise) operator
This sets the output bits only where both input bits are 1. this is used
for finding out the intersection of 2 sets of flags (ie what they have in
common)
It's late here. I hope some of this makes sense. :)
--
Rory