OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: Rommel92 on 18 Oct 2009, 03:38:45
-
I have a solution, simply convert the bools to strings and then compare them, but why does this error like this? I always viewed comparisons as Boolean logic anyway?
-
To me it makes since because unless it's converted to a string, then the booleans will always be compiled as true or false.
if(_bool1 && _bool2) then {_bothtrue=true;}
if(!(_bool1 || _bool2)) then {_bothfalse=true;}
-
tcp, while you are technically right, equal or not equal comparisons between booleans are commonly used in any language (well, except this).
-
Another thing to keep in mind is that if you have a single boolean you don't have to compare it to anything:
_isTrue = true;
if _isTrue then {
// do something in case it's true
};
if not _isTrue then {
// do something in case it's false
};
-
#define xor(A,B) (!(A && B) && (A || B))
// example
if( xor(flip, flop) ) then { flop = !flop }
-
xor, flip, flop?
Planck
-
Planck, yes, using xor possible to compare boolean values:
(true xor true) === (true != true) === false
(false xor false) === (false != false) === false
(false xor true) === (false != true) === true
(true xor false) === (true != false) === true
A xor B === (A or B) and (not A or not B)
A xor B === (A and not B) or (B and not A)
A xor B === (not (A and B)) and (A or B)
-
ok, I understand, I thought you meant there was an actual xor operator in the commands list.
Planck
-
I found this was suffice.
(true and true) or not(true and true)