PHP - gmp_clrbit() 函式



定義和用法

gmp_clrbit() 函式清除位。

描述

gmp_clrbit() 在給定的 GMP 數字中清除並將位索引設定為 0。索引從 0 開始。

語法

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

引數

序號 引數及描述
1

num

它可以是 GMP 資源數字、gmp 物件或數字字串。

2

index

要清除的位的索引。索引 0 是使用的最低有效位。

返回值

PHP gmp_clrbit() 函式返回 GMP 資源或 gmp 物件。

PHP 版本

此函式將在 PHP 5.0.0 及更高版本中執行。

示例 1

gmp_clrbit 的工作原理 -

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

這將產生以下結果 -

254

示例 2

使用索引為 2 -

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

這將產生以下結果 -

1096

示例 3

使用十六進位制數字,索引為 7 -

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

這將產生以下結果 -

0
php_function_reference.htm
廣告