gmp_setbit() - gmp库(多精度计算)
gmp_setbit()
(PHP 4 >= 4.0.4, PHP 5, PHP 7)
Set bit
说明
gmp_setbit(GMP$a,int $index[,bool $bit_on=TRUE
]): voidSets bit$indexin$a.
参数
$aThe value to modify.
可以是一个 GMP数据resouce,或一个可以转换为数值的字符串。
$indexThe index of the bit to set. Index 0 represents the least significant bit.
$bit_onTrue to set the bit(set it to 1/on); false to clear the bit(set it to 0/off).
返回值
GMP 数值资源.
范例
gmp_setbit() example - 0 index
以上例程会输出:
2 -> 0b10 3 -> 0b11
gmp_setbit() example - 1 index
以上例程会输出:
253 -> 0b11111101 255 -> 0b11111111
gmp_setbit() example - clearing a bit
以上例程会输出:
255 -> 0b11111111 254 -> 0b11111110
注释
Note:Unlike most of the other GMP functions,gmp_setbit() must be called with a GMP resource that already exists(using gmp_init() for example). One will not be automatically created.
参见
gmp_clrbit()
Clear bitgmp_testbit()
Tests if a bit is set
The third parameter is somewhat confusingly named; it would probably be better described as "$set_state". If true, it sets the bit to 1. If false, it sets the bit to 0. Default is true.
鹏仔微信 15129739599 鹏仔QQ344225443 鹏仔前端 pjxi.com 共享博客 sharedbk.com
图片声明:本站部分配图来自网络。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!