1--TEST-- 2gmp_divexact() tests 3--SKIPIF-- 4<?php 5if (!extension_loaded("gmp")) die ("skip"); 6if (!defined('GMP_VERSION') || version_compare("4.2.1", GMP_VERSION, ">=")) { 7 die("skip your GMP is too old and will crash"); 8} 9?> 10--FILE-- 11<?php 12 13$r = gmp_divexact("233", "23345555555555555555555555"); 14var_dump(gmp_strval($r)); 15 16try { 17 $r = gmp_divexact("233", "0"); 18 var_dump(gmp_strval($r)); 19} catch (\DivisionByZeroError $e) { 20 echo $e->getMessage() . \PHP_EOL; 21} 22 23$r = gmp_divexact("100", "10"); 24var_dump(gmp_strval($r)); 25 26$r = gmp_divexact("1024", "2"); 27var_dump(gmp_strval($r)); 28 29$n = gmp_init("10000000000000000000"); 30$r = gmp_divexact($n, "2"); 31var_dump(gmp_strval($r)); 32 33$r = gmp_divexact($n, "50"); 34var_dump(gmp_strval($r)); 35 36$n1 = gmp_init("-100000000000000000000000000"); 37$r = gmp_divexact($n1, $n); 38var_dump(gmp_strval($r)); 39 40echo "Done\n"; 41?> 42--EXPECT-- 43string(1) "0" 44Division by zero 45string(2) "10" 46string(3) "512" 47string(19) "5000000000000000000" 48string(18) "200000000000000000" 49string(9) "-10000000" 50Done 51