1--TEST--
2bcmul() checking overflow
3--EXTENSIONS--
4bcmath
5--INI--
6bcmath.scale=0
7--FILE--
8<?php
9for ($i = 1; $i < 15; $i++) {
10    $repeat = 2 ** $i;
11    $num1 = str_repeat('99999999', $repeat);
12    /*
13     * 9999 * 9999 = 99980001
14     * 99999999 * 99999999 = 9999999800000001
15     */
16    $expected = str_repeat('9', $repeat * 8 - 1) . '8' . str_repeat('0', $repeat * 8 - 1) . '1';
17    $actual = bcmul($num1, $num1);
18    echo $repeat . ': ' . ($actual === $expected ? 'OK' : 'NG') . PHP_EOL;
19}
20?>
21--EXPECT--
222: OK
234: OK
248: OK
2516: OK
2632: OK
2764: OK
28128: OK
29256: OK
30512: OK
311024: OK
322048: OK
334096: OK
348192: OK
3516384: OK
36