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