qn

This is a discussion on qn within the C Programming forums, part of the General Programming Boards category; can anyone tell me what are these two lines for: kdeltas = kstates ^ buttons; // kstates = buttons;...

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    19

    qn

    can anyone tell me what are these two lines for:
    kdeltas = kstates ^ buttons; //
    kstates = buttons;

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    ^ is the symbol for binary xor. kdeltas is equal to kstates where a bit is inverted if that bit in buttons is on. the second statement just assigns buttons to kstates


    In other words:
    buttons is a set of bits, like any integer is a set of bits. Somewhere your program set buttons as something so that the program could later specify the states to trigger.

    kstates is also a set of bits, where each bit is a state of true or false. when xor'ed with buttons, some states in kstates can be switched to their opposite

    kdeltas just stores the value produced by kstates

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Have no idea how to compile c++, please help (newbie qn)
    By rholloway in forum C++ Programming
    Replies: 3
    Last Post: 02-23-2008, 07:31 AM
  2. Replies: 12
    Last Post: 10-22-2006, 08:37 PM
  3. a simple qn
    By bennyho03 in forum C Programming
    Replies: 4
    Last Post: 09-25-2004, 10:46 AM
  4. qn on Microsoft Developer Studio generated resource script
    By Raison in forum Windows Programming
    Replies: 2
    Last Post: 05-29-2004, 11:49 AM
  5. Quick Qn bout arrays!
    By Mr_J_Cake in forum C Programming
    Replies: 4
    Last Post: 03-22-2003, 05:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21