Computer >> Computer tutorials >  >> Programming >> PHP

gmp_testbit() function in PHP


The gmp_testbit() function test if the specified bit of a given GMP number is set.

Syntax

gmp_testbit(val, index)

Parameters

  • val: The number for which the specified bit is to be checked.
  • index: The index whose bit in val is to be checked.

Return

The gmp_testbit() function returns true if the specified index bit is set.

Example

The following is an example:

<?php
   $val = "9";
   $index = 3;
   var_dump(gmp_testbit($val, $index));
?>

Output

The following is the output:

bool(true)