Re: bitvector question

From: Rob Baumstark (shirak@CONNECT.AB.CA)
Date: 04/27/98


>Is there an easy way to compare two bitvectors and find what the difference
>is between the two?
>
>For example:
>character A has AFF_BLIND|AFF_CURSE|AFF_BERSERK
>character B has AFF_BLIND
Well..., assuming A and B are ints (or whatever), then A&B should return all
of them that are the same, in this case AFF_BLIND.  A-(A&B) would then
return just what A has that they both don't, AFF_CURSE and AFF_BERSERK.
Don't have to worry about subtracking a bit thats not there, because it
wouldn't exist in (A&B).  If you want what is in one or the other, but not
both, an XOR will do (A^B)
------------------------------------------------------------
G:  "If we do happen to step on a mine, Sir, what do we do?"
EB: "Normal procedure, Lieutenant, is to jump 200 feet in
     the air and scatter oneself over a wide area."
-- Somewhere in No Man's Land, BA4
------------------------------------------------------------
     Rob Baumstark:   shirak@connect.ab.ca
                      cst0656@nait.ab.ca
------------------------------------------------------------


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST