XOR result different with PC application


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2008
    Posts
    66

    Question XOR result different with PC application

    In Picbasic Pro,

    a var word
    b var word
    c var word


    c = a ^ b

    But using PC to calculate XOR between a and b, I got a different value than c above.

    In both of these cases, when I XOR the result back with b, I can get back a.

    Any idea?

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Because "^" is a PBP command for a BITWISE (bit-by-bit) exclusive or. The PC is using a LOGICAL exclusive or. To get the same result as the PC, use the "^^" or XOR PBP commands.
    Charles Linquist

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Pic2008 View Post
    c = a ^ b
    On a PC, that means a to the power of b.
    DT

Similar Threads

  1. Send data to PC USB
    By konter in forum Off Topic
    Replies: 2
    Last Post: - 18th December 2009, 21:57
  2. RS232 into 2 PC ports
    By manxman in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th August 2008, 13:33
  3. Sending menu to PC from PIC16F876A
    By joseph Degorio in forum Serial
    Replies: 2
    Last Post: - 12th November 2007, 07:03
  4. PIC16F877 sends/receives data to/from a PC
    By ovidiu in forum Serial
    Replies: 1
    Last Post: - 2nd December 2006, 14:09
  5. Interrupt and Serial communication to PC.
    By obaskirt in forum mel PIC BASIC
    Replies: 2
    Last Post: - 17th June 2005, 20:01

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts