Annotation of embedaddon/php/ext/gmp/tests/bug52906.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Bug #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: );
19: foreach($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: }
25: echo "Done\n";
26: ?>
27: --EXPECTF--
28: 7%3=1
29: 7%3=1
30: 2%7=2
31: 2%7=2
32: 12%7=5
33: 12%7=5
34: -2%7=5
35: -2%7=5
36: -12%7=2
37: -12%7=2
38: 2%-7=2
39: 2%-7=2
40: 12%-7=5
41: 12%-7=5
42: -2%-7=5
43: -2%-7=5
44: -12%-7=2
45: -12%-7=2
46: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>