PHP Gmp_scan0 () function

PHP

Syntax:
gmp_scan0 ($num, $index)
Parameters:this function takes two parameters as described below:
  • $num : This parameter is a GMP number and must be passed. This parameter can be a GMP object in PHP 5.6 and above, or we are also allowed to pass a numeric string, provided that the string can be converted to a number.
  • $index : This parameter represents the index or position in bitwise representation of the number $num from which we want to start the search.
Return value:The function returns the position at which we find "0" in number.Examples:
Input: gmp_scan0 ("101111101", 6) Output: 7 Input: gmp_scan0 ("111001111", 2) Output: 4
The following programs illustrate the gmp_scan0() function in PHP:Program 1:A program to find the position of the "0" bit in a GMP number when numeric strings are passed as GMP numbers to as arguments. < tr>  
// PHP program to find the position of the bit "0" in GMP
// number passed as arguments 
// strings as GMP numbers $num = "10110001" ; $pos = 2; echo gmp_scan0 ( $num , $pos ). "" ;  
?>
Output:
6  Program 2 : A program to find the position of the 0 bit in a GMP number when GMP numbers are passed as arguments.      
// PHP program to find the position of the bit" 0 " in GMP
// number 
// generate GMP numbers using gmp_init() $num = gmp_init (10001111101); $pos = 2; echo gmp_scan0 ( $num , $pos ). "" ;  
?>
Output:
7  Link:
http: //php.net/manual/en/function.gmp-scan0.php



Get Solution for free from DataCamp guru