Javatpoint Logo
Javatpoint Logo

PHP gmp_setbit() function

PHP programming language works with various GMP functions to operate with numerical values. The GMP function gmp_setbit() sets the index number in the base number. The function is used with three parameters, which are GMP, integer, and Boolean values. The function represents the "void" data type, and the first parameter is essential in the function.

Syntax

The syntax shows the GMP function to set the given number in the GMP base parameter.

Parameters

  • The function takes three parameters to set the bit in the input value.
  • A first parameter represents GMP value ($base_value), second parameter represents integer value ($index_value) and a third parameter represents Boolean value ($index_value).
  • The gmp_setbit() function and its operation depend on the parameters.
  • The gmp_setbit() function works on the PHP 5.6 and afterward version with various input data.
    • $base_value: it is the essential GMP parameter to set the integer data and return the output of the function.
    • $index_value: it is the essential integer parameter ($index_value) to provide required bit to the base value. the parameter "0" bit represents the least bit value.
    • $bit_num: This parameter sets the bits in Boolean format. If the value uses the "True," the function makes the bit 1 (on). If the value uses "False," the function makes the bit 0 (off).

Return Value

This function gives the GMP parameter as an output of the given data.

Examples

The examples show the GMP function to set the required bit using base and index values.

Example1: In the given example, set the index bit value using essential parameters. Here, we are using different base numbers and different index numbers.

Output:

The output image displays the set bit of the GMP parameter.

PHP gmp_setbit() function

Example2: In the given an example, set the index bit value using essential parameters. Here, we are using the same base numbers and different index numbers.

Output:

The output image displays the set bit of the GMP parameter.

PHP gmp_setbit() function

Example3: In the given an example, set the index bit value using essential parameters. Here, we are using the same base numbers and same index numbers with a Boolean set bit.

Output:

The output image displays the set bit of the GMP parameter.

PHP gmp_setbit() function

Example4: In the given an example, set the index bit value using essential parameters. Here, we use negative base numbers and binary index numbers with GMP parameters.

Output:

The output image displays the set bit of the GMP parameter.

PHP gmp_setbit() function

Example5: In the given an example, set the index bit value using the required parameters. Here, we are using negative base numbers and integer index numbers.

Output:

The output image displays the set bit of the GMP parameter.

PHP gmp_setbit() function

Conclusion

The "gmp_setbit()" function is used to set the required value of the given GMP parameter. It helps to set values for other random range data operations and their 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