xref: /PHP-8.3/ext/gmp/tests/gmp_pow_fpe.phpt (revision e0a0e216)
1--TEST--
2gmp_pow() floating point exception
3--EXTENSIONS--
4gmp
5--FILE--
6<?php
7$g = gmp_init(256);
8
9try {
10	gmp_pow($g, PHP_INT_MAX);
11} catch (\ValueError $e) {
12	echo $e->getMessage() . PHP_EOL;
13}
14try {
15	gmp_pow(256, PHP_INT_MAX);
16} catch (\ValueError $e) {
17	echo $e->getMessage() . PHP_EOL;
18}
19
20try {
21    gmp_pow(gmp_add(gmp_mul(gmp_init(PHP_INT_MAX), gmp_init(PHP_INT_MAX)), 3), 256);
22} catch (\ValueError $e) {
23	echo $e->getMessage() . PHP_EOL;
24}
25try {
26    gmp_pow(gmp_init(PHP_INT_MAX), 256);
27} catch (\ValueError $e) {
28	echo $e->getMessage();
29}
30?>
31--EXPECTF--
32base and exponent overflow
33base and exponent overflow
34base and exponent overflow
35base and exponent overflow
36