PDA

View Full Version : Did I find a bug or bug found me?



sayzer
- 12th September 2008, 09:53
</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?
________________

skimask
- 12th September 2008, 11:42
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...

Acetronics2
- 12th September 2008, 12:56
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

tenaja
- 12th September 2008, 22:06
</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...

Archangel
- 12th September 2008, 22:25
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.

sayzer
- 13th September 2008, 08:19
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.

Acetronics2
- 13th September 2008, 09:58
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