1--TEST--
2Test % operator : 64bit long tests
3--SKIPIF--
4<?php
5if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
6?>
7--FILE--
8<?php
9
10define("MAX_64Bit", 9223372036854775807);
11define("MAX_32Bit", 2147483647);
12define("MIN_64Bit", -9223372036854775807 - 1);
13define("MIN_32Bit", -2147483647 - 1);
14
15$longVals = array(
16    MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit,
17    MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1,
18    MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1
19);
20
21$otherVals = array(0, 1, -1, 7, 9, 65, -44, MAX_32Bit, MAX_64Bit);
22
23error_reporting(E_ERROR);
24
25foreach ($longVals as $longVal) {
26   foreach($otherVals as $otherVal) {
27	  echo "--- testing: $longVal % $otherVal ---\n";
28	  try {
29	    var_dump($longVal%$otherVal);
30      } catch (DivisionByZeroError $e) {
31        echo "Exception: " . $e->getMessage() . "\n";
32      }
33   }
34}
35
36foreach ($otherVals as $otherVal) {
37   foreach($longVals as $longVal) {
38	  echo "--- testing: $otherVal % $longVal ---\n";
39	  try {
40        var_dump($otherVal%$longVal);
41      } catch (DivisionByZeroError $e) {
42        echo "Exception: " . $e->getMessage() . "\n";
43      }
44   }
45}
46
47?>
48===DONE===
49--EXPECT--
50--- testing: 9223372036854775807 % 0 ---
51Exception: Modulo by zero
52--- testing: 9223372036854775807 % 1 ---
53int(0)
54--- testing: 9223372036854775807 % -1 ---
55int(0)
56--- testing: 9223372036854775807 % 7 ---
57int(0)
58--- testing: 9223372036854775807 % 9 ---
59int(7)
60--- testing: 9223372036854775807 % 65 ---
61int(7)
62--- testing: 9223372036854775807 % -44 ---
63int(7)
64--- testing: 9223372036854775807 % 2147483647 ---
65int(1)
66--- testing: 9223372036854775807 % 9223372036854775807 ---
67int(0)
68--- testing: -9223372036854775808 % 0 ---
69Exception: Modulo by zero
70--- testing: -9223372036854775808 % 1 ---
71int(0)
72--- testing: -9223372036854775808 % -1 ---
73int(0)
74--- testing: -9223372036854775808 % 7 ---
75int(-1)
76--- testing: -9223372036854775808 % 9 ---
77int(-8)
78--- testing: -9223372036854775808 % 65 ---
79int(-8)
80--- testing: -9223372036854775808 % -44 ---
81int(-8)
82--- testing: -9223372036854775808 % 2147483647 ---
83int(-2)
84--- testing: -9223372036854775808 % 9223372036854775807 ---
85int(-1)
86--- testing: 2147483647 % 0 ---
87Exception: Modulo by zero
88--- testing: 2147483647 % 1 ---
89int(0)
90--- testing: 2147483647 % -1 ---
91int(0)
92--- testing: 2147483647 % 7 ---
93int(1)
94--- testing: 2147483647 % 9 ---
95int(1)
96--- testing: 2147483647 % 65 ---
97int(62)
98--- testing: 2147483647 % -44 ---
99int(23)
100--- testing: 2147483647 % 2147483647 ---
101int(0)
102--- testing: 2147483647 % 9223372036854775807 ---
103int(2147483647)
104--- testing: -2147483648 % 0 ---
105Exception: Modulo by zero
106--- testing: -2147483648 % 1 ---
107int(0)
108--- testing: -2147483648 % -1 ---
109int(0)
110--- testing: -2147483648 % 7 ---
111int(-2)
112--- testing: -2147483648 % 9 ---
113int(-2)
114--- testing: -2147483648 % 65 ---
115int(-63)
116--- testing: -2147483648 % -44 ---
117int(-24)
118--- testing: -2147483648 % 2147483647 ---
119int(-1)
120--- testing: -2147483648 % 9223372036854775807 ---
121int(-2147483648)
122--- testing: 9223372034707292160 % 0 ---
123Exception: Modulo by zero
124--- testing: 9223372034707292160 % 1 ---
125int(0)
126--- testing: 9223372034707292160 % -1 ---
127int(0)
128--- testing: 9223372034707292160 % 7 ---
129int(6)
130--- testing: 9223372034707292160 % 9 ---
131int(6)
132--- testing: 9223372034707292160 % 65 ---
133int(10)
134--- testing: 9223372034707292160 % -44 ---
135int(28)
136--- testing: 9223372034707292160 % 2147483647 ---
137int(1)
138--- testing: 9223372034707292160 % 9223372036854775807 ---
139int(9223372034707292160)
140--- testing: -9223372034707292160 % 0 ---
141Exception: Modulo by zero
142--- testing: -9223372034707292160 % 1 ---
143int(0)
144--- testing: -9223372034707292160 % -1 ---
145int(0)
146--- testing: -9223372034707292160 % 7 ---
147int(-6)
148--- testing: -9223372034707292160 % 9 ---
149int(-6)
150--- testing: -9223372034707292160 % 65 ---
151int(-10)
152--- testing: -9223372034707292160 % -44 ---
153int(-28)
154--- testing: -9223372034707292160 % 2147483647 ---
155int(-1)
156--- testing: -9223372034707292160 % 9223372036854775807 ---
157int(-9223372034707292160)
158--- testing: 2147483648 % 0 ---
159Exception: Modulo by zero
160--- testing: 2147483648 % 1 ---
161int(0)
162--- testing: 2147483648 % -1 ---
163int(0)
164--- testing: 2147483648 % 7 ---
165int(2)
166--- testing: 2147483648 % 9 ---
167int(2)
168--- testing: 2147483648 % 65 ---
169int(63)
170--- testing: 2147483648 % -44 ---
171int(24)
172--- testing: 2147483648 % 2147483647 ---
173int(1)
174--- testing: 2147483648 % 9223372036854775807 ---
175int(2147483648)
176--- testing: -2147483649 % 0 ---
177Exception: Modulo by zero
178--- testing: -2147483649 % 1 ---
179int(0)
180--- testing: -2147483649 % -1 ---
181int(0)
182--- testing: -2147483649 % 7 ---
183int(-3)
184--- testing: -2147483649 % 9 ---
185int(-3)
186--- testing: -2147483649 % 65 ---
187int(-64)
188--- testing: -2147483649 % -44 ---
189int(-25)
190--- testing: -2147483649 % 2147483647 ---
191int(-2)
192--- testing: -2147483649 % 9223372036854775807 ---
193int(-2147483649)
194--- testing: 4294967294 % 0 ---
195Exception: Modulo by zero
196--- testing: 4294967294 % 1 ---
197int(0)
198--- testing: 4294967294 % -1 ---
199int(0)
200--- testing: 4294967294 % 7 ---
201int(2)
202--- testing: 4294967294 % 9 ---
203int(2)
204--- testing: 4294967294 % 65 ---
205int(59)
206--- testing: 4294967294 % -44 ---
207int(2)
208--- testing: 4294967294 % 2147483647 ---
209int(0)
210--- testing: 4294967294 % 9223372036854775807 ---
211int(4294967294)
212--- testing: 4294967295 % 0 ---
213Exception: Modulo by zero
214--- testing: 4294967295 % 1 ---
215int(0)
216--- testing: 4294967295 % -1 ---
217int(0)
218--- testing: 4294967295 % 7 ---
219int(3)
220--- testing: 4294967295 % 9 ---
221int(3)
222--- testing: 4294967295 % 65 ---
223int(60)
224--- testing: 4294967295 % -44 ---
225int(3)
226--- testing: 4294967295 % 2147483647 ---
227int(1)
228--- testing: 4294967295 % 9223372036854775807 ---
229int(4294967295)
230--- testing: 4294967293 % 0 ---
231Exception: Modulo by zero
232--- testing: 4294967293 % 1 ---
233int(0)
234--- testing: 4294967293 % -1 ---
235int(0)
236--- testing: 4294967293 % 7 ---
237int(1)
238--- testing: 4294967293 % 9 ---
239int(1)
240--- testing: 4294967293 % 65 ---
241int(58)
242--- testing: 4294967293 % -44 ---
243int(1)
244--- testing: 4294967293 % 2147483647 ---
245int(2147483646)
246--- testing: 4294967293 % 9223372036854775807 ---
247int(4294967293)
248--- testing: 9223372036854775806 % 0 ---
249Exception: Modulo by zero
250--- testing: 9223372036854775806 % 1 ---
251int(0)
252--- testing: 9223372036854775806 % -1 ---
253int(0)
254--- testing: 9223372036854775806 % 7 ---
255int(6)
256--- testing: 9223372036854775806 % 9 ---
257int(6)
258--- testing: 9223372036854775806 % 65 ---
259int(6)
260--- testing: 9223372036854775806 % -44 ---
261int(6)
262--- testing: 9223372036854775806 % 2147483647 ---
263int(0)
264--- testing: 9223372036854775806 % 9223372036854775807 ---
265int(9223372036854775806)
266--- testing: 9.2233720368548E+18 % 0 ---
267Exception: Modulo by zero
268--- testing: 9.2233720368548E+18 % 1 ---
269int(0)
270--- testing: 9.2233720368548E+18 % -1 ---
271int(0)
272--- testing: 9.2233720368548E+18 % 7 ---
273int(-1)
274--- testing: 9.2233720368548E+18 % 9 ---
275int(-8)
276--- testing: 9.2233720368548E+18 % 65 ---
277int(-8)
278--- testing: 9.2233720368548E+18 % -44 ---
279int(-8)
280--- testing: 9.2233720368548E+18 % 2147483647 ---
281int(-2)
282--- testing: 9.2233720368548E+18 % 9223372036854775807 ---
283int(-1)
284--- testing: -9223372036854775807 % 0 ---
285Exception: Modulo by zero
286--- testing: -9223372036854775807 % 1 ---
287int(0)
288--- testing: -9223372036854775807 % -1 ---
289int(0)
290--- testing: -9223372036854775807 % 7 ---
291int(0)
292--- testing: -9223372036854775807 % 9 ---
293int(-7)
294--- testing: -9223372036854775807 % 65 ---
295int(-7)
296--- testing: -9223372036854775807 % -44 ---
297int(-7)
298--- testing: -9223372036854775807 % 2147483647 ---
299int(-1)
300--- testing: -9223372036854775807 % 9223372036854775807 ---
301int(0)
302--- testing: -9.2233720368548E+18 % 0 ---
303Exception: Modulo by zero
304--- testing: -9.2233720368548E+18 % 1 ---
305int(0)
306--- testing: -9.2233720368548E+18 % -1 ---
307int(0)
308--- testing: -9.2233720368548E+18 % 7 ---
309int(-1)
310--- testing: -9.2233720368548E+18 % 9 ---
311int(-8)
312--- testing: -9.2233720368548E+18 % 65 ---
313int(-8)
314--- testing: -9.2233720368548E+18 % -44 ---
315int(-8)
316--- testing: -9.2233720368548E+18 % 2147483647 ---
317int(-2)
318--- testing: -9.2233720368548E+18 % 9223372036854775807 ---
319int(-1)
320--- testing: 0 % 9223372036854775807 ---
321int(0)
322--- testing: 0 % -9223372036854775808 ---
323int(0)
324--- testing: 0 % 2147483647 ---
325int(0)
326--- testing: 0 % -2147483648 ---
327int(0)
328--- testing: 0 % 9223372034707292160 ---
329int(0)
330--- testing: 0 % -9223372034707292160 ---
331int(0)
332--- testing: 0 % 2147483648 ---
333int(0)
334--- testing: 0 % -2147483649 ---
335int(0)
336--- testing: 0 % 4294967294 ---
337int(0)
338--- testing: 0 % 4294967295 ---
339int(0)
340--- testing: 0 % 4294967293 ---
341int(0)
342--- testing: 0 % 9223372036854775806 ---
343int(0)
344--- testing: 0 % 9.2233720368548E+18 ---
345int(0)
346--- testing: 0 % -9223372036854775807 ---
347int(0)
348--- testing: 0 % -9.2233720368548E+18 ---
349int(0)
350--- testing: 1 % 9223372036854775807 ---
351int(1)
352--- testing: 1 % -9223372036854775808 ---
353int(1)
354--- testing: 1 % 2147483647 ---
355int(1)
356--- testing: 1 % -2147483648 ---
357int(1)
358--- testing: 1 % 9223372034707292160 ---
359int(1)
360--- testing: 1 % -9223372034707292160 ---
361int(1)
362--- testing: 1 % 2147483648 ---
363int(1)
364--- testing: 1 % -2147483649 ---
365int(1)
366--- testing: 1 % 4294967294 ---
367int(1)
368--- testing: 1 % 4294967295 ---
369int(1)
370--- testing: 1 % 4294967293 ---
371int(1)
372--- testing: 1 % 9223372036854775806 ---
373int(1)
374--- testing: 1 % 9.2233720368548E+18 ---
375int(1)
376--- testing: 1 % -9223372036854775807 ---
377int(1)
378--- testing: 1 % -9.2233720368548E+18 ---
379int(1)
380--- testing: -1 % 9223372036854775807 ---
381int(-1)
382--- testing: -1 % -9223372036854775808 ---
383int(-1)
384--- testing: -1 % 2147483647 ---
385int(-1)
386--- testing: -1 % -2147483648 ---
387int(-1)
388--- testing: -1 % 9223372034707292160 ---
389int(-1)
390--- testing: -1 % -9223372034707292160 ---
391int(-1)
392--- testing: -1 % 2147483648 ---
393int(-1)
394--- testing: -1 % -2147483649 ---
395int(-1)
396--- testing: -1 % 4294967294 ---
397int(-1)
398--- testing: -1 % 4294967295 ---
399int(-1)
400--- testing: -1 % 4294967293 ---
401int(-1)
402--- testing: -1 % 9223372036854775806 ---
403int(-1)
404--- testing: -1 % 9.2233720368548E+18 ---
405int(-1)
406--- testing: -1 % -9223372036854775807 ---
407int(-1)
408--- testing: -1 % -9.2233720368548E+18 ---
409int(-1)
410--- testing: 7 % 9223372036854775807 ---
411int(7)
412--- testing: 7 % -9223372036854775808 ---
413int(7)
414--- testing: 7 % 2147483647 ---
415int(7)
416--- testing: 7 % -2147483648 ---
417int(7)
418--- testing: 7 % 9223372034707292160 ---
419int(7)
420--- testing: 7 % -9223372034707292160 ---
421int(7)
422--- testing: 7 % 2147483648 ---
423int(7)
424--- testing: 7 % -2147483649 ---
425int(7)
426--- testing: 7 % 4294967294 ---
427int(7)
428--- testing: 7 % 4294967295 ---
429int(7)
430--- testing: 7 % 4294967293 ---
431int(7)
432--- testing: 7 % 9223372036854775806 ---
433int(7)
434--- testing: 7 % 9.2233720368548E+18 ---
435int(7)
436--- testing: 7 % -9223372036854775807 ---
437int(7)
438--- testing: 7 % -9.2233720368548E+18 ---
439int(7)
440--- testing: 9 % 9223372036854775807 ---
441int(9)
442--- testing: 9 % -9223372036854775808 ---
443int(9)
444--- testing: 9 % 2147483647 ---
445int(9)
446--- testing: 9 % -2147483648 ---
447int(9)
448--- testing: 9 % 9223372034707292160 ---
449int(9)
450--- testing: 9 % -9223372034707292160 ---
451int(9)
452--- testing: 9 % 2147483648 ---
453int(9)
454--- testing: 9 % -2147483649 ---
455int(9)
456--- testing: 9 % 4294967294 ---
457int(9)
458--- testing: 9 % 4294967295 ---
459int(9)
460--- testing: 9 % 4294967293 ---
461int(9)
462--- testing: 9 % 9223372036854775806 ---
463int(9)
464--- testing: 9 % 9.2233720368548E+18 ---
465int(9)
466--- testing: 9 % -9223372036854775807 ---
467int(9)
468--- testing: 9 % -9.2233720368548E+18 ---
469int(9)
470--- testing: 65 % 9223372036854775807 ---
471int(65)
472--- testing: 65 % -9223372036854775808 ---
473int(65)
474--- testing: 65 % 2147483647 ---
475int(65)
476--- testing: 65 % -2147483648 ---
477int(65)
478--- testing: 65 % 9223372034707292160 ---
479int(65)
480--- testing: 65 % -9223372034707292160 ---
481int(65)
482--- testing: 65 % 2147483648 ---
483int(65)
484--- testing: 65 % -2147483649 ---
485int(65)
486--- testing: 65 % 4294967294 ---
487int(65)
488--- testing: 65 % 4294967295 ---
489int(65)
490--- testing: 65 % 4294967293 ---
491int(65)
492--- testing: 65 % 9223372036854775806 ---
493int(65)
494--- testing: 65 % 9.2233720368548E+18 ---
495int(65)
496--- testing: 65 % -9223372036854775807 ---
497int(65)
498--- testing: 65 % -9.2233720368548E+18 ---
499int(65)
500--- testing: -44 % 9223372036854775807 ---
501int(-44)
502--- testing: -44 % -9223372036854775808 ---
503int(-44)
504--- testing: -44 % 2147483647 ---
505int(-44)
506--- testing: -44 % -2147483648 ---
507int(-44)
508--- testing: -44 % 9223372034707292160 ---
509int(-44)
510--- testing: -44 % -9223372034707292160 ---
511int(-44)
512--- testing: -44 % 2147483648 ---
513int(-44)
514--- testing: -44 % -2147483649 ---
515int(-44)
516--- testing: -44 % 4294967294 ---
517int(-44)
518--- testing: -44 % 4294967295 ---
519int(-44)
520--- testing: -44 % 4294967293 ---
521int(-44)
522--- testing: -44 % 9223372036854775806 ---
523int(-44)
524--- testing: -44 % 9.2233720368548E+18 ---
525int(-44)
526--- testing: -44 % -9223372036854775807 ---
527int(-44)
528--- testing: -44 % -9.2233720368548E+18 ---
529int(-44)
530--- testing: 2147483647 % 9223372036854775807 ---
531int(2147483647)
532--- testing: 2147483647 % -9223372036854775808 ---
533int(2147483647)
534--- testing: 2147483647 % 2147483647 ---
535int(0)
536--- testing: 2147483647 % -2147483648 ---
537int(2147483647)
538--- testing: 2147483647 % 9223372034707292160 ---
539int(2147483647)
540--- testing: 2147483647 % -9223372034707292160 ---
541int(2147483647)
542--- testing: 2147483647 % 2147483648 ---
543int(2147483647)
544--- testing: 2147483647 % -2147483649 ---
545int(2147483647)
546--- testing: 2147483647 % 4294967294 ---
547int(2147483647)
548--- testing: 2147483647 % 4294967295 ---
549int(2147483647)
550--- testing: 2147483647 % 4294967293 ---
551int(2147483647)
552--- testing: 2147483647 % 9223372036854775806 ---
553int(2147483647)
554--- testing: 2147483647 % 9.2233720368548E+18 ---
555int(2147483647)
556--- testing: 2147483647 % -9223372036854775807 ---
557int(2147483647)
558--- testing: 2147483647 % -9.2233720368548E+18 ---
559int(2147483647)
560--- testing: 9223372036854775807 % 9223372036854775807 ---
561int(0)
562--- testing: 9223372036854775807 % -9223372036854775808 ---
563int(9223372036854775807)
564--- testing: 9223372036854775807 % 2147483647 ---
565int(1)
566--- testing: 9223372036854775807 % -2147483648 ---
567int(2147483647)
568--- testing: 9223372036854775807 % 9223372034707292160 ---
569int(2147483647)
570--- testing: 9223372036854775807 % -9223372034707292160 ---
571int(2147483647)
572--- testing: 9223372036854775807 % 2147483648 ---
573int(2147483647)
574--- testing: 9223372036854775807 % -2147483649 ---
575int(1)
576--- testing: 9223372036854775807 % 4294967294 ---
577int(1)
578--- testing: 9223372036854775807 % 4294967295 ---
579int(2147483647)
580--- testing: 9223372036854775807 % 4294967293 ---
581int(2147483650)
582--- testing: 9223372036854775807 % 9223372036854775806 ---
583int(1)
584--- testing: 9223372036854775807 % 9.2233720368548E+18 ---
585int(9223372036854775807)
586--- testing: 9223372036854775807 % -9223372036854775807 ---
587int(0)
588--- testing: 9223372036854775807 % -9.2233720368548E+18 ---
589int(9223372036854775807)
590===DONE===
591