• PHP Video Tutorials

PHP - gmp_clrbit() Function



Definition and Usage

The gmp_clrbit() function clears the bit .

Description

gmp_clrbit() clears and sets the bit index to 0 in the given GMP number. The index starts from 0.

Syntax

gmp_clrbit ( GMP $num , int $index ) : void

Parameters

Sr.No Parameter & Description
1

num

It can a GMP resource number , a gmp object or a numeric string .

2

index

The index of the bit to clear.The index 0 is the least significant bit used.

Return Values

PHP gmp_clrbit() function returns a GMP resource or a gmp object.

PHP Version

This function will work from PHP Version greater than 5.0.0.

Example 1

Working of gmp_clrbit −

<?php
   $a = gmp_init("255");
   gmp_clrbit($a, 0); 
   echo gmp_strval($a);
?>

This will produce following result −

254

Example 2

Using index as 2 −

<?php
   $a = gmp_init("1100");
   gmp_clrbit($a, 2); 
   echo gmp_strval($a) . "\n";
?>

This will produce following result −

1096

Example 3

Using hexadecimal number with index as 7 −

<?php
   $a = gmp_init("0x80");
   gmp_clrbit($a, 7); 
   echo gmp_strval($a);
?>

This will produce following result −

0
php_function_reference.htm
Advertisements