<?php
$a = gmp_init("0xff");
echo gmp_strval($a), ' -> 0b', gmp_strval($a, 2), "\n";
gmp_setbit($a, 0, false); // clear bit at index 0
echo gmp_strval($a), ' -> 0b', gmp_strval($a, 2), "\n";
?>
The above example will output:
255 -> 0b11111111
254 -> 0b11111110
Notes
Note:
Unlike most of the other GMP functions, gmp_setbit()
must be called with a GMP object that already exists (using
gmp_init() for example). One will not be
automatically created.