Did I find a bug or bug found me?


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185

    Default Did I find a bug or bug found me?

    Code:
    </i></font>A <font color="#000080"><b>VAR BYTE
    </b></font>B <font color="#000080"><b>VAR BYTE
    </b></font>C <font color="#000080"><b>VAR BYTE
    </b></font>D <font color="#000080"><b>VAR BYTE
    
    </b></font>A = <font color="#FF0000">100
    </font>B = <font color="#FF0000">100
    </font>C = <font color="#FF0000">100
    </font>D = <font color="#FF0000">100
    
    
    </font>Loop:
    
        <font color="#000080"><b>IF </b></font>A = B = C = D = <font color="#FF0000">100 </font><font color="#000080"><b>THEN </b></font>Loop
        
    <font color="#000080"><b>GOTO </b></font>Loop
    This code compiles with no error; but in practice, it does not come out true.


    Am I going to learn something new now?
    ________________
    Last edited by sayzer; - 12th September 2008 at 09:56.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer View Post
    This code compiles with no error; but in practice, it does not come out true.

    Am I going to learn something new now?
    The only thing I could find in the book:
    4.18. Comparison Operators
    Comparison operators are used in IF..THEN statements to compare
    one expression with another. These comparisons are unsigned. They
    cannot be used to check if a number is less than 0.
    ....which to me implies that you can ONLY compare ONE to ANOTHER, not one to another to another to another.
    But you're right, looks good, don't work so good...

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Talking

    Hi, Sayzer

    "IF A = B = C = D = 100 THEN Loop"


    A ?= B ... result is TRUE ( 1)

    1 ?= C ... result is FALSE ( 0 )

    0 ?= D ... result is FALSE ( 0 )

    0 ? = 100 ... result is FALSE ...


    Too bad for the Nobel Prize ...

    You win another chance to be known.

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer View Post
    Code:
    </font>Loop:
    
        <font color="#000080"><b>IF </b></font>A = B = C = D = <font color="#FF0000">100 </font><font color="#000080"><b>THEN </b></font>Loop
        
    <font color="#000080"><b>GOTO </b></font>Loop
    Try using the AND...
    if a=b and b=c and c=d and d=100 then loop

    ... but of course, there are more efficient ways to do it...

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Sayzer

    "IF A = B = C = D = 100 THEN Loop"


    A ?= B ... result is TRUE ( 1)

    1 ?= C ... result is FALSE ( 0 )

    0 ?= D ... result is FALSE ( 0 )

    0 ? = 100 ... result is FALSE ...


    Too bad for the Nobel Prize ...

    You win another chance to be known.

    Alain
    If I understand correctly, I think Sayzer's point was, it should fail to compile or at least throw an error message.
    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.

  6. #6
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    You understood it right, Joe.

    The line looks simple, should always be "true" in theory.
    But, in practice, it compiles and there is no error message.

    The result is "false".

    That was my point.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Wink

    Hi, Sayzer

    From the "grammatical" point of view there's nothing forbidden ...

    Just try :

    IF A = B = 1 THEN ...

    or IF A = B = 0 THEN ... if A <> B !!!



    or WHILE A = B = 1
    WEND....


    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Instant Interrupts - Revisited
    By Darrel Taylor in forum Code Examples
    Replies: 772
    Last Post: - 17th February 2016, 22:14
  2. PBPro error "Macro USBINIT? not found in macro file"
    By Bonxy in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th October 2011, 09:06
  3. can't find include file!
    By jimbostlawrence in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 10th November 2009, 08:44
  4. Found something strange (BUG???)
    By GrandPa in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th November 2007, 19:50
  5. 18F452 "Unknown Processor" errors
    By schwinn_rider in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 27th April 2006, 03:56

Members who have read this thread : 1

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