Message-ID: <33D36DA3.7EB2@lr.net> Date: Mon, 21 Jul 1997 10:09:39 -0400 From: Isaac Waldron Reply-To: waldroni AT lr DOT net Organization: The Computer Nerd MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Bit-wise compare Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk I am working on an RPG computer game, and I was wondering if it is possible to do the following: #include const int WEAPON_SWORD_1 = 1; const int WEAPON_SWORD_2 = 2; int has_item(int a, int b) { if (a && b) { return 1; } else { return 0; }; }; int main() { int a, b, c, d; a = a || WEAPON_SWORD_1; b = b || WEAPON_SWORD_2; c = has_item(b, WEAPON_SWORD_1); d = has_item(a, WEAPON_SWORD_2); cout << d << " " << c; return 0; }; What I want has_item to do is see if the bit that is set in b is also set in a. That way, I could use one variable to determine equipment on the character. I also replaced all the int's with float's, but that didn't work. Any help is appreciated, -- -Begin Signature- Isaac Waldron N1YZI http://www.geocities.com/SiliconValley/Lakes/5703/home.html -End Signature-