why is: (test := 2<1 or 4>2 and 7<8) true?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Gibbons
Posts: 93
Joined: 20 Sep 2016, 20:39

why is: (test := 2<1 or 4>2 and 7<8) true?

05 Aug 2021, 09:05

I'm lacking something fundamental in my understanding of OR and AND operators.

test is true in the following statement:

test := 2<1 OR 4>2 AND 7<8

I'm breaking it down like this, but I'm obviously wrong:

test := False OR True AND False
becomes:
test := True AND False
becomes:
test := False(0)

but the value of test comes back as 1(True).

can somebody explain?

Thanks!
User avatar
mikeyww
Posts: 26938
Joined: 09 Sep 2014, 18:38

Re: why is: (test := 2<1 or 4>2 and 7<8) true?

05 Aug 2021, 09:12

AND has precedence as an operator.

Another fact is that 7 is less than 8.
Gibbons
Posts: 93
Joined: 20 Sep 2016, 20:39

Re: why is: (test := 2<1 or 4>2 and 7<8) true?

05 Aug 2021, 09:16

I considered this but then I come up with:

test := False OR True AND False
becomes:
test := False OR False
becomes:
test := False(0)

which again there is flaw in my thinking.
User avatar
mikeyww
Posts: 26938
Joined: 09 Sep 2014, 18:38

Re: why is: (test := 2<1 or 4>2 and 7<8) true?

05 Aug 2021, 09:18

It worked for me.

Code: Select all

Send % False OR True AND False
Your initial statement is true because the last two expressions are true.
Gibbons
Posts: 93
Joined: 20 Sep 2016, 20:39

Re: why is: (test := 2<1 or 4>2 and 7<8) true?

05 Aug 2021, 09:24

Got it. I'm obviously having a bad go of it today.
Thanks.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, TAC109, wineguy and 300 guests