11--TEST--
2- bcround() and BcMath\Number::round() reject out-of-range $precision
2+ bcround() and BcMath\Number::round() reject $precision above INT_MAX
33--EXTENSIONS--
44bcmath
55--SKIPIF--
1111} catch (\ValueError $ e ) {
1212 echo $ e ->getMessage () . \PHP_EOL ;
1313}
14- try {
15- bcround ('12345 ' , -PHP_INT_MAX , RoundingMode::AwayFromZero);
16- } catch (\ValueError $ e ) {
17- echo $ e ->getMessage () . \PHP_EOL ;
18- }
19- try {
20- bcround ('12345 ' , PHP_INT_MIN , RoundingMode::AwayFromZero);
21- } catch (\ValueError $ e ) {
22- echo $ e ->getMessage () . \PHP_EOL ;
23- }
2414try {
2515 (new BcMath \Number ('1 ' ))->round (PHP_INT_MAX );
2616} catch (\ValueError $ e ) {
@@ -31,10 +21,12 @@ try {
3121} catch (\ValueError $ e ) {
3222 echo $ e ->getMessage () . \PHP_EOL ;
3323}
24+
25+ // Large negative precision is accepted: result is a power of 10.
26+ echo bcround ('1 ' , -5 , RoundingMode::AwayFromZero) . \PHP_EOL ;
3427?>
3528--EXPECTF--
36- bcround(): Argument #2 ($precision) must be between %i and %i
37- bcround(): Argument #2 ($precision) must be between %i and %i
38- bcround(): Argument #2 ($precision) must be between %i and %i
39- BcMath\Number::round(): Argument #1 ($precision) must be between %i and %i
40- BcMath\Number::round(): Argument #1 ($precision) must be between %i and %i
29+ bcround(): Argument #2 ($precision) must be between %i and %d
30+ BcMath\Number::round(): Argument #1 ($precision) must be between %i and %d
31+ BcMath\Number::round(): Argument #1 ($precision) must be between %i and %d
32+ 100000
0 commit comments