1--TEST--
2Test bindec 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$binLongStrs = array(
16   '0'.str_repeat('1',63),
17   str_repeat('1',64),
18   '0'.str_repeat('1',31),
19   str_repeat('1',32),
20   '0'.str_repeat('1',64),
21   str_repeat('1',65),
22   '0'.str_repeat('1',32),
23   str_repeat('1',33)
24);
25
26
27foreach ($binLongStrs as $strVal) {
28   echo "--- testing: $strVal ---\n";
29   var_dump(bindec($strVal));
30}
31
32?>
33--EXPECT--
34--- testing: 0111111111111111111111111111111111111111111111111111111111111111 ---
35int(9223372036854775807)
36--- testing: 1111111111111111111111111111111111111111111111111111111111111111 ---
37float(1.8446744073709552E+19)
38--- testing: 01111111111111111111111111111111 ---
39int(2147483647)
40--- testing: 11111111111111111111111111111111 ---
41int(4294967295)
42--- testing: 01111111111111111111111111111111111111111111111111111111111111111 ---
43float(1.8446744073709552E+19)
44--- testing: 11111111111111111111111111111111111111111111111111111111111111111 ---
45float(3.6893488147419103E+19)
46--- testing: 011111111111111111111111111111111 ---
47int(4294967295)
48--- testing: 111111111111111111111111111111111 ---
49int(8589934591)
50