Core Function BitXOR
From Sputnik Wiki
(Difference between revisions)
(Created page with "<pre> BitXOR( <expression>, <expression2>, <n> ) </pre> === Description === Performs a bitwise exclusive OR (XOR) operation. === Parameters === ==== expression ==== The firs...") |
(→Example) |
||
Line 45: | Line 45: | ||
// Another method | // Another method | ||
− | $x = 3 | + | $x = 3 ^ 7; |
println($x); | println($x); | ||
− | $x = 3 | + | $x = 3 ^ 15 ^ 32; |
println($x); | println($x); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] |
Revision as of 06:24, 30 April 2013
BitXOR( <expression>, <expression2>, <n> )
Contents |
Description
Performs a bitwise exclusive OR (XOR) operation.
Parameters
expression
The first number.
expression2
The second number.
n
Optional; The nth number - up to 255 values can be specified.
Return Value
Returns the value of the parameters bitwise-XOR'ed together.
Bit operations are performed as 32-bit integers.
Remarks
Remember hex notation can be used for numbers.
Remember that XOR returns 1 if exactly one bit is 1 and returns 0 otherwise.
Some might wonder the point of such a function when clear ^ operators exist but why not!.
Example
$x = BitOR(3, 6); println($x); // x == is 7 because 0011 OR 0110 = 0111 $x = BitOR(3, 15, 32); println($x); //x == 47 because 0011 OR 1111 OR 00100000 = 00101111 // Another method $x = 3 ^ 7; println($x); $x = 3 ^ 15 ^ 32; println($x);