gmp_pow2.phpt 547 B

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