PHP Gmp_clrbit () Function

PHP

Syntax:
gmp_clrbit ($num, $index) 
Parameters:the function takes two required parameters $numand $index,as shown in the above syntax. These parameters are: -
  • $num:This can be either a GMP number resource in PHP 5.5, a GMP object in PHP 5.6 and later, or numeric strings can be passed to a function, provided the strings can be converted to numbers.
  • $index:the index of the bit to be cleared. Indexing starts at 0, where index 0 represents the least significant bit.
Return Values:This function returns a GMP number (in PHP 5.5 and earlier) or an object GMP (in PHP 5.6 and later), which is a number generated after the bit at the specified index is set to 0.Examples:
 Input: $num = 255, $index = 0 Output: 254 Input: $num = 128, $index = 7 Output: 0 
The programs below illustrate the gmp_clrbit() function:Program 1 :
// PHP illustration program
// gmp_clrbit() function $num = gmp_init (255); gmp_clrbit ( $num , 0); // index starts at 0, least significant bit echo gmp_strval ( $num ); ?>
Exit :
254 
Program 2 :
// PHP illustration program
// gmp_clrbit() function $num = gmp_init ( "314567128" ); gmp_clrbit ( $num , 8); // index starts at 0, least significant bit echo gmp_strval ( $num ); ?>
Exit :
314566872 
Link: http://php.net/manual/en/function.gmp-clrbit.php



Get Solution for free from DataCamp guru