1--TEST--
2Test decbin function : 64bit long tests
3--SKIPIF--
4<?php
5if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
6?>
7--FILE--
8<?php
9
10define("MAX_64Bit", 9223372036854775807);
11define("MAX_32Bit", 2147483647);
12define("MIN_64Bit", -9223372036854775807 - 1);
13define("MIN_32Bit", -2147483647 - 1);
14
15$longVals = array(
16    MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit,
17    MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1,
18    MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1
19);
20
21
22foreach ($longVals as $longVal) {
23    echo "--- testing: $longVal ---\n";
24    try {
25        var_dump(decbin($longVal));
26    } catch (TypeError $exception) {
27        echo $exception->getMessage() . "\n";
28    }
29}
30
31?>
32--EXPECT--
33--- testing: 9223372036854775807 ---
34string(63) "111111111111111111111111111111111111111111111111111111111111111"
35--- testing: -9223372036854775808 ---
36string(64) "1000000000000000000000000000000000000000000000000000000000000000"
37--- testing: 2147483647 ---
38string(31) "1111111111111111111111111111111"
39--- testing: -2147483648 ---
40string(64) "1111111111111111111111111111111110000000000000000000000000000000"
41--- testing: 9223372034707292160 ---
42string(63) "111111111111111111111111111111110000000000000000000000000000000"
43--- testing: -9223372034707292160 ---
44string(64) "1000000000000000000000000000000010000000000000000000000000000000"
45--- testing: 2147483648 ---
46string(32) "10000000000000000000000000000000"
47--- testing: -2147483649 ---
48string(64) "1111111111111111111111111111111101111111111111111111111111111111"
49--- testing: 4294967294 ---
50string(32) "11111111111111111111111111111110"
51--- testing: 4294967295 ---
52string(32) "11111111111111111111111111111111"
53--- testing: 4294967293 ---
54string(32) "11111111111111111111111111111101"
55--- testing: 9223372036854775806 ---
56string(63) "111111111111111111111111111111111111111111111111111111111111110"
57--- testing: 9.2233720368548E+18 ---
58decbin(): Argument #1 ($num) must be of type int, float given
59--- testing: -9223372036854775807 ---
60string(64) "1000000000000000000000000000000000000000000000000000000000000001"
61--- testing: -9.2233720368548E+18 ---
62string(64) "1000000000000000000000000000000000000000000000000000000000000000"
63