Page 1 of 1

-1 should return false?

Posted: Sat Apr 28, 2007 4:30 pm
by Joakim Christiansen

Code: Select all

If -1
  Debug "Returned true"
EndIf
I think only that a value over 0 should return true, isn't this the case in most languages? Or am I just being silly now? What do you guys think?

Posted: Sat Apr 28, 2007 4:45 pm
by AND51
No.
Only 0 (zero) returns False.
Any other values return true.

Code: Select all

x=1
y=0
z=-1

If x
   Debug "true"
Endif
If y
   Debug "true"
Endif
If z
   Debug "true"
Endif
You can imagine this behaviour better, if you imageine that an If-query looks like this:

Code: Select all

If x = anything
   Debug "true"
Endif
'anything' can be any value, except for 0.

Posted: Sat Apr 28, 2007 4:48 pm
by Trond
In fact, in many other languages -1 is used instead of 1 if a true boolean needs to be represented as an integer.