Core Function BitXOR

From Sputnik Wiki
Jump to: navigation, search
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 - no limit to number of values that 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);
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox