PHP GMP gmp_testbit() FunctionPHP 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. SyntaxThe following syntax shows a clear bit function using GMP numbers. ParametersThe function requires two input parameters, $input_value and $index_value.
Return Valuespecific value. The false value represents not setting a specific value. ExamplesUsing 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. 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. 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. 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. 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. 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. ConclusionThe 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. Next TopicPHP gmp_random() function |