xref: /PHP-7.0/ext/gmp/tests/003.phpt (revision 5408f1e5)
1--TEST--
2Check for number base recognition
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
5--FILE--
6<?php
7        /* Binary */
8        $test[] = gmp_init("0b10011010010");
9        $test[] = gmp_init("0b10011010010", 2);
10        $test[] = gmp_init("10011010010");
11        $test[] = gmp_init("10011010010", 2);
12
13        /* Octal */
14        $test[] = gmp_init("02322");
15        $test[] = gmp_init("02322", 8);
16        $test[] = gmp_init("2322");
17        $test[] = gmp_init("2322", 8);
18
19        /* Decimal */
20        $test[] = gmp_init("1234");
21        $test[] = gmp_init("1234", 10);
22
23        /* Hexidecimal */
24        $test[] = gmp_init("0x4d2");
25        $test[] = gmp_init("0x4d2", 16);
26        $test[] = gmp_init("4d2");
27        $test[] = gmp_init("4d2", 16);
28
29        for ($i = 0; $i < count($test); $i++) {
30                printf("%s\n", gmp_strval($test[$i]));
31        }
32?>
33--EXPECTF--
34Warning: gmp_init(): Unable to convert variable to GMP - string is not an integer in %s on line %d
351234
361234
3710011010010
381234
391234
401234
412322
421234
431234
441234
451234
461234
470
481234
49