Cover Image for PHP gmp_or() function
169 views

PHP gmp_or() function

As of my last update in September 2021, the gmp_or() function in PHP is used to perform the bitwise OR operation on two GMP (GNU Multiple Precision) numbers. The bitwise OR operation sets each bit in the result to 1 if at least one of the corresponding bits in the operands is 1.

Here’s the syntax of the gmp_or() function:

GMP gmp_or ( GMP $num1 , GMP $num2 )

Parameters:

  • $num1: The first GMP number.
  • $num2: The second GMP number.

Return value:

  • The result of the bitwise OR operation as a new GMP number.

Here’s a simple example demonstrating the usage of gmp_or():

$num1 = gmp_init('12'); // Binary representation: 1100
$num2 = gmp_init('5');  // Binary representation: 0101

$result = gmp_or($num1, $num2);

echo gmp_strval($result); // Output: 13 (Binary representation: 1101)

In this example, the bitwise OR of 12 (binary 1100) and 5 (binary 0101) results in 13 (binary 1101).

Please ensure that you have the GMP extension enabled in your PHP configuration to use this function. Also, be aware that the availability of functions may change in newer PHP versions, so always refer to the PHP manual for the specific version you are using.

YOU MAY ALSO LIKE...

The Tech Thunder

The Tech Thunder

The Tech Thunder


COMMENTS