Javatpoint Logo
Javatpoint Logo

PHP GMP gmp_testbit() Function

PHP language provides a built-in function called GMP gmp_testbit(). This function is used to test whether a particular bit of a GMP number is set or not set. The gmp_testbit() function helps to identify a set number with the help of the base and index values.

Syntax

The following syntax shows a clear bit function using GMP numbers.

Parameters

The function requires two input parameters, $input_value and $index_value.

  • $input_value: It can be a GMP number parameter for the function in PHP version 5.6 and above. This function is used to test the specific value. The string value turns into numerical data for the function.
  • $index_value: The number of the bit checks in the input value ($input_value).

Return Value

specific value. The false value represents not setting a specific value.

Examples

Using the GMP parameters, the following examples test a particular bit (gmp_testbit) function.

Example1: The following example checks the specific bit of the value using the GMP function and parameters.

Output:

The following image shows the GMP gmp_testbit() function output.

PHP GMP gmp_testbit() Function

Example2: The following example checks the specific bit of the value using the negative input parameters.

Output:

The following image shows the GMP gmp_testbit() function output.

PHP GMP gmp_testbit() Function

Example3: The following example checks the specific bit of the value using the variable as an input parameter.

Output:

The following image shows the GMP gmp_testbit() function output.

PHP GMP gmp_testbit() Function

Example4: The following example checks the specific bit of the value using the variable and GMP parameter as input data.

Output:

The following image shows the GMP gmp_testbit() function output.

PHP GMP gmp_testbit() Function

Example5: The following example checks the specific bit of the value using the variable and GMP parameter as input data. Here, we use binary value as the input base number.

Output:

The following image shows the GMP gmp_testbit() function output.

PHP GMP gmp_testbit() Function

Example6: The following example checks the specific bit of the value using the variable and GMP parameter as input data. Here, we use an integer value as the input base number.

Output:

The following image shows the GMP gmp_testbit() function output.

PHP GMP gmp_testbit() Function

Conclusion

The gmp_testbit() function identify if the particular value is set in base value or not. It minimizes the programming length for developers and makes it easy for users. It works on the numerical value and displays output in the Boolean format.







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