xref: /PHP-5.6/ext/gmp/tests/bug52906.phpt (revision b55d4ecb)
1--TEST--
2Bug #52906 gmp_mod returns negative result when non-negative is expected
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
5--FILE--
6<?php
7
8$vals = array(
9	array(7, 3),
10	array(2, 7),
11	array(12, 7),
12	array(-2, 7),
13	array(-12, 7),
14	array(2, -7),
15	array(12, -7),
16	array(-2, -7),
17	array(-12, -7),
18);
19foreach($vals as $data) {
20	echo "{$data[0]}%{$data[1]}=".gmp_strval(gmp_mod($data[0], $data[1]));
21	echo "\n";
22	echo "{$data[0]}%{$data[1]}=".gmp_strval(gmp_mod(gmp_init($data[0]), gmp_init($data[1])));
23	echo "\n";
24}
25echo "Done\n";
26?>
27--EXPECTF--
287%3=1
297%3=1
302%7=2
312%7=2
3212%7=5
3312%7=5
34-2%7=5
35-2%7=5
36-12%7=2
37-12%7=2
382%-7=2
392%-7=2
4012%-7=5
4112%-7=5
42-2%-7=5
43-2%-7=5
44-12%-7=2
45-12%-7=2
46Done
47