Javatpoint Logo
Javatpoint Logo

PHP gmp_scan1() function

The PHP programming language provides various GMP functions and data to operate with numeric operations. The GMP function gmp_scan1() is used to "scan to 1 bit" of the GMP parameter using the index value. The input number scans to 1 using index value towards the largest or most significant number.

Syntax

The syntax shows the GMP function to scan the "1" number towards the most significant GMP parameter.

Parameters

  • The function requires two parameters: the first parameter for $base_value and a second parameter for the $index_value. The gmp_scan1() function and its operation depend on both variables.
  • The GMP function works on the PHP 5.6 and above version with various input data. The GMP string value turns into the number.
    • $base_value: it is the GMP parameter of the integer data returns as the base value's part or output of the function. It finds the position of the 1 bit of the base value.
    • $index_value: it is the integer parameter to scan 1 of the $base_value using the $index_value.

Return Value

This function shows the numerical or integer output after scanning to the "1" of the given GMP data.

Examples

The examples show the GMP function to scan the "1" bit using base and index values.

Example1: the given an example displays the position of the 1-bit value using essential parameters. Here we are using the same base value with different index values.

Output:

The output image shows a scan of the 1-bit value of the input data.

PHP gmp_scan1() function

Example2: the given an example displays the position of the 1-bit value using essential parameters. Here we use different base values with the same index value.

Output:

The output image shows a scan of the 1-bit value of the input data.

PHP gmp_scan1() function

Example3: the given an example displays the position of the 1-bit value using essential parameters. Here we use different base values with different index values

Output:

The output image shows a scan of the 1-bit value of the input data.

PHP gmp_scan1() function

Example4: the given an example displays the position of the 0-bit value using essential parameters.

Output:

The output image shows a scan of the 1-bit value of the input data.

PHP gmp_scan1() function

Example5: the given example displays the position of the 1-bit value using essential parameters. Here, we use the GMP parameters and function with the gmp_scan1() function.

Output:

The output image shows a scan of the 1-bit value of the input data.

PHP gmp_scan1() function

Conclusion

The gmp_scan1() function displays the position of the "1" bit in the given number. This function helps to get output using a single line function.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA