SA-MP Forums Archive
xor - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: xor (/showthread.php?tid=517804)



xor - ATomas - 06.06.2014

Has pawn something like a pascal xor?

Like this:

pawn Код:
if(a = b xor c = d) then ...
pawn Код:
true xor true = false
true xor false = true
false xor true = true
false xor false = false



Re: xor - Vince - 06.06.2014

There is only bitwise XOR which is '^' but only works with integers. However, it must be noted that in Pawn && and || do not evaluate any further expressions if the result of the expression has already been determined. For example:

pawn Код:
if(e1 = true || e2 = false) // will not evaluate e2, result: true
if(e1 = false || e2 = true) // will evaluate both expression, result: true

if(e1 = true && e2 = true) // will evaluate both expression, result: true
if(e1 = false && e2 = true) // will not evaluate e2, result: false
Edit: I think it may be solved with this construct:
pawn Код:
if((e1 && !e2) || (e2 && !e1))



Re: xor - ATomas - 06.06.2014

Thanks for the advice.
If I have for example 5 conditions where must be met only once. I'll die before he could write complicated way