Logical vs Bitwise ==


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818

    Default Logical vs Bitwise ==

    Hello Everyone,
    I understand the difference between & vs &&, and I understand >= , <= , but what is the difference between = , and ==, is this just some "C" sneaking into peoples code or is there an esoteric difference here ? Or did I just miss that page in DAS BOOK ? As a comparison operator is there a difference ?
    Bewildered
    Last edited by Archangel; - 16th February 2010 at 07:07.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    As a comparision operator they both do the same thing.
    As a statement only "=" will work.

    Why the MeLabs folks did it this way is anyones guess.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Thanks Dave, I pretty much thought so, Never tried using double = as a statement, so that's good to know too.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Ok I just found this, re: double equal sign in " C "
    From Jan 2010 Circuit Cellar
    author: George Martin
    page 70
    "Consider the statements if (a=b) and if (a==b). Both are

    correct, but they are vastly different operations. The former copies the

    value of variable b into variable a, and then if that value

    is nonzero (TRUE) it executes the next statement. The latter compares

    variable a to variable b . If they are equal, then the next

    statement is executed. It is a common mistake to leave out the double

    equal sign."
    Is this true for PBP ?
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    PBP
    Code:
    XRUN:
    IF (A == B) THEN X = Z
    
    RUNX:
    IF (A = B) THEN X = Z
    Generated ASM
    Code:
            LABEL?L	_XRUN	
    	CMPNE?BBL	_A, _B, L00001
    	MOVE?BB	_Z, _X
    	LABEL?L	L00001	
    
    	LABEL?L	_RUNX	
    	CMPNE?BBL	_A, _B, L00003
    	MOVE?BB	_Z, _X
    	LABEL?L	L00003
    Looks the same to me..
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    C != pbp . . . . .
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    C != pbp . . . . .
    That will not compile...
    Can not use a comparison operator as a statement....
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default GeekSpeak

    Quote Originally Posted by mackrackit View Post
    That will not compile...
    Can not use a comparison operator as a statement....
    You're right! it should be
    main:
    If C != PBP Then Gosub buy
    goto main
    Buy:
    Buy PBP
    return
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. 4 Bytes one button press
    By Dennis in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 15th January 2010, 22:36
  2. ISD17240 on PIC16F88
    By drewcog in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 17th December 2008, 20:07
  3. shifting problem
    By helmut in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 31st August 2007, 06:11
  4. Bitwise Operators
    By SterlingY in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th March 2007, 05:57
  5. Bitwise not working
    By Ioannis in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 19th October 2006, 07:31

Members who have read this thread : 2

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