PHP | gmp_scan0() Function (original) (raw)

Last Updated : 11 Jul, 2025

The gmp_scan0() is an inbuilt function which is used to scan "0" in a GMP number(GNU Multiple Precision : For large numbers) starting from given index which move towards most significant bits in the number.Syntax:

gmp_scan0($num, $index)

Parameters: This function accepts two parameters as explained below:

Return Value: The function returns the position where we find "0" in the number. Examples:

Input : gmp_scan0("101111101", 6) Output : 7

Input : gmp_scan0("111001111", 2) Output : 4

Below programs illustrate the gmp_scan0() function in PHP:Program 1: Program to find the position of "0" bit in GMP number when numeric strings as GMP numbers are passed as arguments.

php `

`

Output:

6

Program 2: Program to find the position of "0" bit in GMP number when GMP numbers are passed as arguments.

php `

`

Output:

7

Reference: https://www.php.net/manual/en/function.gmp-scan0.php