xref: /PHP-8.4/ext/gmp/tests/gmp_clrbit.phpt (revision e9f783fc)
1--TEST--
2gmp_clrbit() basic tests
3--EXTENSIONS--
4gmp
5--FILE--
6<?php
7
8$n = gmp_init(0);
9gmp_clrbit($n, 0);
10var_dump(gmp_strval($n));
11
12$n = gmp_init(-1);
13try {
14    gmp_clrbit($n, -1);
15} catch (\ValueError $e) {
16    echo $e->getMessage() . \PHP_EOL;
17}
18var_dump(gmp_strval($n));
19
20$n = gmp_init("1000000");
21try {
22    gmp_clrbit($n, -1);
23} catch (\ValueError $e) {
24    echo $e->getMessage() . \PHP_EOL;
25}
26var_dump(gmp_strval($n));
27
28$n = gmp_init("1000000");
29gmp_clrbit($n, 3);
30var_dump(gmp_strval($n));
31
32$n = gmp_init("238462734628347239571823641234");
33gmp_clrbit($n, 3);
34gmp_clrbit($n, 5);
35gmp_clrbit($n, 20);
36var_dump(gmp_strval($n));
37
38$n = array();
39try {
40    gmp_clrbit($n, 3);
41} catch (TypeError $e) {
42    echo $e->getMessage(), "\n";
43}
44
45echo "Done\n";
46?>
47--EXPECT--
48string(1) "0"
49gmp_clrbit(): Argument #2 ($index) must be greater than or equal to 0
50string(2) "-1"
51gmp_clrbit(): Argument #2 ($index) must be greater than or equal to 0
52string(7) "1000000"
53string(7) "1000000"
54string(30) "238462734628347239571822592658"
55gmp_clrbit(): Argument #1 ($num) must be of type GMP, array given
56Done
57