1--TEST-- 2gmp_testbit() basic tests 3--EXTENSIONS-- 4gmp 5--FILE-- 6<?php 7 8$n = gmp_init(0); 9 10try { 11 var_dump(gmp_testbit($n, -10)); 12} catch (\ValueError $e) { 13 echo $e->getMessage() . \PHP_EOL; 14} 15 16var_dump(gmp_testbit($n, 0)); 17var_dump(gmp_testbit($n, 1)); 18var_dump(gmp_testbit($n, 100)); 19 20$n = gmp_init(-1); 21var_dump(gmp_testbit($n, 1)); 22try { 23 var_dump(gmp_testbit($n, -1)); 24} catch (\ValueError $e) { 25 echo $e->getMessage() . \PHP_EOL; 26} 27 28$n = gmp_init("1000000"); 29var_dump(gmp_testbit($n, 1)); 30gmp_setbit($n, 1); 31var_dump(gmp_testbit($n, 1)); 32var_dump(gmp_strval($n)); 33 34gmp_setbit($n, 5); 35var_dump(gmp_testbit($n, 5)); 36var_dump(gmp_strval($n)); 37 38$n = gmp_init("238462734628347239571823641234"); 39var_dump(gmp_testbit($n, 5)); 40gmp_setbit($n, 5); 41var_dump(gmp_testbit($n, 5)); 42var_dump(gmp_strval($n)); 43 44gmp_clrbit($n, 5); 45var_dump(gmp_testbit($n, 5)); 46var_dump(gmp_strval($n)); 47 48echo "Done\n"; 49?> 50--EXPECT-- 51gmp_testbit(): Argument #2 ($index) must be greater than or equal to 0 52bool(false) 53bool(false) 54bool(false) 55bool(true) 56gmp_testbit(): Argument #2 ($index) must be greater than or equal to 0 57bool(false) 58bool(true) 59string(7) "1000002" 60bool(true) 61string(7) "1000034" 62bool(false) 63bool(true) 64string(30) "238462734628347239571823641266" 65bool(false) 66string(30) "238462734628347239571823641234" 67Done 68