Jump to content
Sign in to follow this  
seandisanti

Possible bug using mathematical expressions for boolean checks

Recommended Posts

seandisanti

it doesn't seem like this should display 2 message boxes, but it does... I couldn't remember if negatives evaluated as true or false, but rather than check the helpfile, i opened up scite and just wrote a check... then because i had nothing better to do, i threw in a 'Not' to see if the condition evaluated to false, but it didn't...

$a = 2
$b = 3
if $a - $b Then MsgBox(0,"yep","negatives evaluate to true")
if Not $a - $b Then MsgBox(0,"yep","negatives evaluate to true")

Share this post


Link to post
Share on other sites
seandisanti

this

if Not $a - $b Then MsgBox(0,"yep","negatives evaluate to true")

evaluates to ...

(Not $a) - $b

0 -3

try...

if Not ($a - $:P Then MsgBox(0,"yep","negatives evaluate to true")

thanks, didn't even think to check precedence...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.