xref: /php-src/ext/standard/tests/math/intdiv.phpt (revision 007d7ac7)
1--TEST--
2intdiv functionality
3--FILE--
4<?php
5var_dump(intdiv(3, 2));
6var_dump(intdiv(-3, 2));
7var_dump(intdiv(3, -2));
8var_dump(intdiv(-3, -2));
9var_dump(intdiv(PHP_INT_MAX, PHP_INT_MAX));
10var_dump(intdiv(PHP_INT_MIN, PHP_INT_MIN));
11try {
12  var_dump(intdiv(PHP_INT_MIN, -1));
13} catch (Throwable $e) {
14  echo "Exception: " . $e->getMessage() . "\n";
15}
16try {
17  var_dump(intdiv(1, 0));
18} catch (Throwable $e) {
19  echo "Exception: " . $e->getMessage() . "\n";
20}
21
22?>
23--EXPECT--
24int(1)
25int(-1)
26int(-1)
27int(1)
28int(1)
29int(1)
30Exception: Division of PHP_INT_MIN by -1 is not an integer
31Exception: Division by zero
32