xref: /PHP-8.4/ext/gmp/tests/gmp_pow2.phpt (revision e9f783fc)
1--TEST--
2Test pow() with gmp object
3--EXTENSIONS--
4gmp
5--FILE--
6<?php
7
8$n = gmp_init(2);
9var_dump(pow($n, 10));
10var_dump($n ** 10);
11
12try {
13    pow($n, -10);
14} catch (ValueError $exception) {
15    echo $exception->getMessage() . "\n";
16}
17
18try {
19    $n ** -10;
20} catch (ValueError $exception) {
21    echo $exception->getMessage() . "\n";
22}
23
24?>
25--EXPECTF--
26object(GMP)#%d (1) {
27  ["num"]=>
28  string(4) "1024"
29}
30object(GMP)#%d (1) {
31  ["num"]=>
32  string(4) "1024"
33}
34Exponent must be greater than or equal to 0
35Exponent must be greater than or equal to 0
36