Page 1 of 1

Double condition Boolean

PostPosted: Wed Jan 19, 2022 3:40 pm
by Tepeix
Hi
I just find this code line that i didn't know was possible.

X = (a<b)|(b<c);

With this X will be true if b<a or b>c.
Or false only if a<b<c.

Which is the contrary of what i expected...

Did you know a way to make an inverted result or what is supposed to do the | ?
Or another way to make double condition boolean ?

Thanks for any response !)

Re: Double condition Boolean

PostPosted: Thu Jan 20, 2022 12:47 am
by Tepeix
Sorry i was wrong. Inverting my input variables.

Let's say we have Y.

X = (0<Y)|(Y<1); will always be true because Y>0 or Y<1.
X = (0>Y)|(Y>1); is true if Y<0 or Y>1.

X = (0<Y)&(Y<1); is true only when 0<Y<1.

It's also possible to add more condition like
X = (a>b)&(a>c)&(a<d);
X = (a)|(b)|(c);
X = (a&b)|(c&d);