Core Function BitOR

From Sputnik Wiki
Jump to: navigation, search
BitOR( <expression>, <expression2>, <n> )

Contents

Description

Performs a bitwise OR 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 two parameters bitwise-OR'ed together.

Remarks

Remember hex notation can be used for numbers.

Remember that OR returns 0 if both bits are 0 and returns 1 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